Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 :float Q_rsqrt( float number ) 2 :{ 3 : int32_t i; 4 : float x2, y; 5 : const float threehalfs = 1.5F; 6

1 :float Q_rsqrt( float number ) 2 :{ 3 : int32_t i; 4 : float x2, y; 5 : const float threehalfs = 1.5F; 6 : 7 : x2 = number * 0.5F; 8 : y = number; 9 : i = * ( int32_t * ) &y; // evil floating point bit level hacking 10: i = 0x5f3759df - ( i >> 1 ); // what the hugs? 11: y = * ( float * ) &i; 12: y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration, newton's approximation 13: // y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed 14: 15: return y; 16:}

For the variable in part 1, what is the value if you interpret this bit pattern as an IEEE 32-bit floating-point number?

Part 1:

Given that number=0.15625, what is the bit pattern for the variable y and i at line 9 in the above code?

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

More Books

Students also viewed these Databases questions