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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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;
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply