Starting from:

$25

CSC230-Exercise 16 Bitwise Operations Solved

This program contains three empty functions.  You get to fill in the functions to accomplish a few simple bit manipulation tasks.

•   The job of the clear6() function is to clear the six high-order bits in the unsigned short value passed to it.  The function returns the resulting value.  All other bits should be unchanged.

•   The set9() function takes an unsigned short value, passed by address.  Its job is to set the 9 low-order bits in the given value (i.e., set them to 1).  All other bits should be unchanged.

•   The set7() function also takes an unsigned short value passed in by address along with a boolean flag.  If the flag is true, this function should set bit 7 in the given short value.  If the flag is false, it should clear the bit.  All other bits should be unchanged.

Once your program is complete, you should be able to run it as follows:

$ ./bitwise 

----- clear6 -----

03ff

0000

037d

029e

----- set9 -----

ffff 01ff b9ff 19ff

----- set7 -----

ff7f 0080

5af0

4f96

More products