Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language: C Language 1 Introduction The purpose of this assignment is to become more familiar with bit - level representations of integers and floating point

Language: C Language 1 Introduction The purpose of this assignment is to become more familiar with bit-level representations of integers and floating point numbers. Youll do this by solving a series of programming puzzles. Many of these puzzles are quite artificial, but youll find yourself thinking much more about bits in working your way through them. 2 Logistics This is an individual project. All handins are electronic. Clarifications and corrections will be posted on the course Web page. 3 Handout Instructions Like the previous lab assignment, this lab assignment will be deployed to the labs/ directory thats in your home directory on fourier. Recall that each lab assignment will have its own directory inside labs/. The directory for this lab assignment will be called datalab-handoutso its full path will be /labs/datalab-handout. *Acknowledgement: This lab is based on earlier material by Bryant and OHallaron.1 iThe only file you will be modifying in this lab assignment is bits.c in /labs/datalab-handout. b Make sure to read the README file in your /labs/datalab-handout directory for additional helpful instructions on how to carry out this lab. The bits.c file contains a skeleton for each of the 13 programming puzzles. Your assignment is to complete each function skeleton using 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 desired coding style. 4 The Puzzles This section describes the puzzles that you will be solving in bits.c. Table 1 lists the puzzles in rough order of difficulty from easiest to hardest. 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 may also refer to the test functions in tests.c. These are used as reference functions to express the correct behavior of your functions, although they dont satisfy the coding rules for your functions. For the floating-point puzzles, you will implement some common singleprecision floating-point operations. For these puzzles, you are allowed to use standard control structures (conditionals, loops), and you may use both int and unsigned data types, including arbitrary unsigned and integer constants. You may not use any unions, structs, or arrays. Most significantly, you may not use any floating point data types, operations, or constants. Instead, any floatingpoint operand will be passed to the function as having type unsigned, and any returned floating-point value will be of type unsigned. Your code should perform the bit manipulations that implement the specified floating point operations. Please do this 13 functions To compile fshow, switch to the handout directory and type: unix > make You can use fshow to see what an arbitrary pattern represents as a floating-point number: unix >./ fshow 2080374784 Floating point value 2.658455992 e +36 Bit Representation 0 x7c000000, sign =0, exponent = f8, fraction =000000 Normalized .1.0000000000 X 2^(121) You can also give fshow hexadecimal and floating point values, and it will decipher their bit structure. 3 istmax - returns I if x is the maximum, two's complement number, Examples allodidits (0\times F E F R E R D)=0, allodidits (0\times )=1 Yax ops: 12 Rating : 2 int alloddBits(int x ){ return 2; } int negate(int x ){ return 2; } negate - return -X Example: negate (1)=-1. Wax ops: kating : isAscilDigit - return I if 0\times 30\times k=0\times 39(ASCII codes for characters '0' to 'g') Example: isAsciidigit (0\times 35)=1. isAscilDigit (0x3a)=0. isAsciiDigit (0\times 05)=0. Leglal ops: Rating: 3 int isAsciidigit(int x ){ return 2; s}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Infrastructure For Medical Research In Databases

Authors: Thomas Heinis ,Anastasia Ailamaki

1st Edition

1680833480, 978-1680833485

More Books

Students also viewed these Databases questions