Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please explain this bit-wise operation line by line Thank you! * * * * /* * float_f2i - Return bit-level equivalent of expression (int) f

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

image text in transcribed

* * * * /* * float_f2i - Return bit-level equivalent of expression (int) f for floating point argument f. Argument is passed as unsigned int, but it is to be interpreted as the bit-level representation of a single-precision floating point value. * Anything out of range (including NaN and infinity) should return 0x80000000u. Legal ops: Any integer/unsigned operations incl. 11, &&. also if, while * Max ops: 30 Rating: 4 */ int float_f2i(unsigned uf) { * * int exponent = (uf >> 23) & 0xFF; int fraction = uf & 0x7FFFFF; int e = exponent - 127; if(exponent == 0x7F800000) return 0x80000000u; if(!exponent) return 0; if(e 30) return 0x80000000u; fraction = fraction | 0x800000; if (e >= 23) fraction = fraction (e-23); else fraction = fraction >> (23 -e); if(( uf >> 31 ) & 1) return ~fraction + 1; return fraction; }

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_2

Step: 3

blur-text-image_3

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

Oracle Databases On The Web Learn To Create Web Pages That Interface With Database Engines

Authors: Robert Papaj, Donald Burleson

11th Edition

1576100995, 978-1576100998

More Books

Students also viewed these Databases questions