Answered step by step
Verified Expert Solution
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 Introduction The purpose of this assignment is to become more familiar with bitlevel 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. Logistics This is an individual project. All handins are electronic. Clarifications and corrections will be posted on the course Web page. 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 datalabhandoutso its full path will be labsdatalabhandout. Acknowledgement: This lab is based on earlier material by Bryant and OHallaron iThe only file you will be modifying in this lab assignment is bits.c in labsdatalabhandout. b Make sure to read the README file in your labsdatalabhandout directory for additional helpful instructions on how to carry out this lab. The bits.c file contains a skeleton for each of the programming puzzles. Your assignment is to complete each function skeleton using only straightline code for the integer puzzles ie 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 bits. See the comments in bits.c for detailed rules and a discussion of the desired coding style. The Puzzles This section describes the puzzles that you will be solving in bits.c Table 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 floatingpoint puzzles, you will implement some common singleprecision floatingpoint 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 floatingpoint value will be of type unsigned. Your code should perform the bit manipulations that implement the specified floating point operations. Please do this 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 floatingpoint number: unix fshow Floating point value e Bit Representation xc sign exponent f fraction Normalized X You can also give fshow hexadecimal and floating point values, and it will decipher their bit structure. istmax returns I if x is the maximum, two's complement number, Examples allodidits times F E F R E R D allodidits times Yax ops: Rating : int alloddBitsint x return ; int negateint x return ; negate return X Example: negate Wax ops: kating : isAscilDigit return I if times times ktimes ASCII codes for characters to g Example: isAsciidigit times isAscilDigit xa isAsciiDigit times Leglal ops: Rating: int isAsciidigitint x return ; s
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started