Page 1 of 1

data lab manipulating bits assignment /* * upperBits - pads n upper bits with 1's * You may assume 0 <= n <= 32 * Exampl

Posted: Mon May 02, 2022 12:20 pm
by answerhappygod
data lab manipulating bits assignment
/* * upperBits - pads n upper bits with 1's * You may assume 0
<= n <= 32 * Example: upperBits(4) = 0xF0000000 * Legal ops:
! ~ & ^ | + << >> * Max ops: 10 * Rating: 1 */
int upperBits(int n)
{ return 2; }
//#include "subtractionOK.c"
/*
* thirdBits - return word with every third bit (starting
from the LSB) set to 1
* Legal ops: ! ~ & ^ | + << >>
* Max ops: 8
* Rating: 1
*/
int thirdBits(void) {
return 2;
/*
* sign - return 1 if positive, 0 if zero, and -1 if
negative
* Examples: sign(130) = 1
* sign(-23) =
-1
* Legal ops: ! ~ & ^ | + << >>
* Max ops: 10
* Rating: 2
*/
int sign(int x) {
return 2;