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 expression evaluated in part 3, if the bit pattern is evaluated as an IEEE 32-bit floating-point number, what is the value of the mantissa in decimal form?

Part 3:

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

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions