Only available on StudyMode
  • Topic: Floating point, C, Fixed-point arithmetic
  • Pages : 7 (2606 words )
  • Download(s) : 65
  • Published : February 18, 2013
Open Document
Text Preview
15-213/18-213 Fall 2012 Data Lab: Manipulating Bits Assigned: Thu, Aug 30, Due: Thu, Sep 13, 11:59PM Last Possible Time to Turn in: Sun, Sep 16, 11:59PM

For the fastest response, please contact the staff via the mailing list ( for questions about the assignment.

1 Introduction
The purpose of this assignment is to become more familiar with bit-level representations of common patterns, integers, and floating-point numbers. You’ll do this by solving a series of programming “puzzles.” Many of these puzzles are quite artificial, but you’ll find yourself thinking much more about bits in working your way through them.

2 Logistics
• This is an individual project. All handins are electronic using the Autolab service. • You should do all of your work in an Andrew directory, using either the shark machines or a Linux Andrew machine.

3 Logging in to Autolab
All 15-213 labs are being offered this term through a Web service developed by CMU students and faculty called Autolab. Before you can download your lab materials, you will need to update your Autolab account. Point your browser at the Autolab front page You will be asked to authenticate via WebISO. After you authenticate this first time, Autolab will prompt you to update your account information with a nickname. Your nickname is the external name that identifies 1

you on the public scoreboards that Autolab maintains for each assignment, so pick something interesting! You can change your nickname as often as you like. Once you have updated your account information, click on “Save Changes” button, and then select the “Home” link to proceed to the main Autolab page. If you added the class late, you might not be included in Autolab’s list of valid students. In this case, you won’t see the 15-213/18-213 course listed on your Autolab home page. If this happens, just contact the staff.

4 Handout Instructions
Your lab materials are contained in a Unix tar file called datalab-handout.tar, which you can download from Autolab. After logging in to Autolab at you can retrieve the datalab-handout.tar file by selecting “Data Lab − > Download handout”. Start by copying datalab-handout.tar to the Linux Andrew directory in where you plan to do your work. Then give the command linux> tar xvf datalab-handout.tar This will create a directory called datalab-handout that contains a number of files. The only file you will be modifying and handing in is bits.c. The bits.c file contains a skeleton for each of the 13 programming puzzles. Your assignment is to complete each function skeleton following a strict set of coding rules: You may use only straightline code for the integer puzzles (i.e., no loops or conditionals) and a limited number of C arithmetic and logical operators. Specifically, you are only allowed to use the following eight operators: ! ˜ & ˆ | + > A few of the functions further restrict this list. Also, you are not allowed to use any constants longer than 8 bits. See the comments in bits.c for detailed rules and a discussion of the coding rules for each functions. WARNING: Do not let the Windows WinZip program open up your .tar file (many Web browsers are set to do this automatically). Instead, save the file to your AFS directory and use the Linux tar program to extract the files. In general, for this class you should NEVER use any platform other than Linux to modify your files, doing so can cause loss of data (and important work!).

5 The Puzzles
This section describes the puzzles that you will be solving in bits.c.


5.1 Bit Manipulations
Table 1 describes a set of functions that manipulate and test sets of bits. The “Rating” field gives the difficulty rating (the number of points) for the puzzle, and the “Max ops” field gives the maximum number of operators you are allowed to use to implement each function. See the comments in bits.c for more details on the desired behavior of the functions. You...
tracking img