Question: Write a 'c' code for the following puzzles, Bit Manipulations Table 1 describes a set of functions that manipulate and test sets of bits. The

Write a 'c' code for the following puzzles,

Bit Manipulations Table 1 describes a set of functions that manipulate and test sets of bits. The Points field gives 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 bitslab.c for more details on the desired behavior of the functions.

Name Description Points Max Ops

bitAnd(x,y) x & y using only | and 2 8

getByte(x,n) Get byte n from x. 2 6

logicalShift(x,n) Shift right logical. 3 20

bitCount(x) Count the number of 1s in x. 4 40

bang(x) Compute !x without using ! operator. 4 12

Twos Complement Arithmetic Table 2 describes a set of functions that make use of the twos complement representation of integers. Again, refer to the comments in bitslab.c for more information.

Name Description Points Max Ops

tmin() Most negative twos complement integer 1 4

fitsBits(x,n) Does x fit in n bits? 2 15

divpwr2(x,n) Compute x/2 n 2 15

negate(x) -x without negation 2 5

isPositive(x) x > 0? 3 8

isLessOrEqual(x,y) x <= y? 3 24

Floating-Point Operations For this part of the assignment, you will implement some common single-precision floating-point operations. In this section, 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 floating-point 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. Table 3 describes a set of functions that operate on the bit-level representations of floating-point numbers. Refer to the comments in bits.c for more information.

Name Description Points Max Ops

float_neg(uf) Compute -f 4 10

float_i2f(x) Compute (float) x 4 30

float_twice(uf) Computer 2*f 4 30

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!