Answered step by step
Verified Expert Solution
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:}
Given that number=0.15625, what is the bit pattern for the expression ( i >>1 ) after the execution of line 9 in the above code?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started