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:}

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

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

Database Systems For Advanced Applications 27th International Conference Dasfaa 2022 Virtual Event April 11 14 2022 Proceedings Part 2 Lncs 13246

Authors: Arnab Bhattacharya ,Janice Lee Mong Li ,Divyakant Agrawal ,P. Krishna Reddy ,Mukesh Mohania ,Anirban Mondal ,Vikram Goyal ,Rage Uday Kiran

1st Edition

3031001257, 978-3031001253

More Books

Students also viewed these Databases questions

Question

=+31-1 Define memory, and explain how memory is measured.

Answered: 1 week ago

Question

When is it appropriate to use a root cause analysis

Answered: 1 week ago