Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribedimage text in transcribed

* 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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What attracts you about this role?

Answered: 1 week ago

Question

How many states in India?

Answered: 1 week ago

Question

HOW IS MARKETING CHANGING WITH ARTIFITIAL INTELIGENCE

Answered: 1 week ago