Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please explain this bit-wise operation line by line Thank you! * * * * = * = 1 * /* howManyBits - return the minimum

Please explain this bit-wise operation line by line Thank you!

image text in transcribedimage text in transcribed

* * * * = * = 1 * /* howManyBits - return the minimum number of bits required to represent x in two's complement Examples: howManyBits (12) = 5 howManyBits (298) = 10 howManyBits(-5) = 4 howManyBits(0) 1 howManyBits(-1) howManyBits (0x80000000) = 32 * Legal ops: ! ~&^ | + >> Max ops: 90 * Rating: 4 */ int howManyBits(int x) { int n = 0; x = x ^ (x >> 31); n = n + ((!!(x >> (n + 16))) 4); n = n + ((!!(x >> (n + 8))) > (n + 4))) > (n + 2))) > (n + 1)))); n = n + (x >> n); return n + 1; } * * /* * float_abs - Return bit-level equivalent of absolute value of f for floating point argument f. Both the argument and result are passed as unsigned int's, but they are to be interpreted as the bit-level representations of single-precision floating point values. When argument is Nan, return argument.. Legal ops: Any integer/unsigned operations incl. ||, &&. also if, while Max ops: 10 Rating: 2 */ unsigned float_abs(unsigned uf) { * * unsigned x = uf & 0x7FFFFFFF; return x > 0x7F800000 ? uf : x; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago