Question: Help with bitwise functions and solutions, would appreciate some explanations with your work. Thank you * bitMask - Generate a mask consisting of all l's

Help with bitwise functions and solutions, would appreciate some explanations with your work. Thank you

Help with bitwise functions and solutions, would appreciate some explanations with yourwork. Thank you * bitMask - Generate a mask consisting of alll's * lowbit and highbit * Examples: bitMask(5,3) = 0x38 * Assume

* bitMask - Generate a mask consisting of all l's * lowbit and highbit * Examples: bitMask(5,3) = 0x38 * Assume 0 highbit, then mask should be all o's Legal ops: ! ^&^| + >> Max ops: 16 * Rating: 3 */ int bitmask(int highbit, int lowbit) { * * return; * * * ilog2 return floor(log base 2 of x), where x > 0 Example: ilog2(16) = 4 * Legal ops: ! ~&^| + >> * Max ops: 90 * Rating: 4 */ int ilog2(int x) { return 2; } * * * * satMul3 - multiplies by 3, saturating to Tmin or Tmax if overflow * Examples: satMul3(0x10000000) = 0x30000000 satMu13(0x30000000) = OxZFFFFFFF (Saturate to TMax) satMu13(0x70000000) = OxZFFFFFFF (Saturate to TMax) satMu13(OXD0000000) = 0x80000000 (Saturate to TMin) satMu13(OXA0000000) = 0x80000000 (Saturate to TMin) * Legal ops: ! ~&^ + > * Max ops: 25 * Rating: 3 */ int satMul3(int x) { * return 2; * bitMask - Generate a mask consisting of all l's * lowbit and highbit * Examples: bitMask(5,3) = 0x38 * Assume 0 highbit, then mask should be all o's Legal ops: ! ^&^| + >> Max ops: 16 * Rating: 3 */ int bitmask(int highbit, int lowbit) { * * return; * * * ilog2 return floor(log base 2 of x), where x > 0 Example: ilog2(16) = 4 * Legal ops: ! ~&^| + >> * Max ops: 90 * Rating: 4 */ int ilog2(int x) { return 2; } * * * * satMul3 - multiplies by 3, saturating to Tmin or Tmax if overflow * Examples: satMul3(0x10000000) = 0x30000000 satMu13(0x30000000) = OxZFFFFFFF (Saturate to TMax) satMu13(0x70000000) = OxZFFFFFFF (Saturate to TMax) satMu13(OXD0000000) = 0x80000000 (Saturate to TMin) satMu13(OXA0000000) = 0x80000000 (Saturate to TMin) * Legal ops: ! ~&^ + > * Max ops: 25 * Rating: 3 */ int satMul3(int x) { * return 2

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!