Question

1 :float Q_rsqrt( float number ) 2 :{ 3 : int32_t i; 4 : float x2,...

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

Part 6:

Given that number=0.15625, what is the bit pattern for the variable i after the execution of line 10 in the above code?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hello
in the question we find the value of i and then convert it from its hexvalue to the binary bit pattern .After we get the binary bit pattern we just partition the 32 bits of the pattern into 3 segments according to the rules of IEEE 32 bit floating point representation .

Add a comment
Know the answer?
Add Answer to:
1 :float Q_rsqrt( float number ) 2 :{ 3 : int32_t i; 4 : float x2,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help with this assignment. My answers are in bold but I am not getting...

    I need help with this assignment. My answers are in bold but I am not getting the correct output which is also below. Can you please take a look at it. #include   <stdlib.h> #include   <stdio.h> #include   <float.h> #include   <math.h> // PURPOSE: To define a nickname for type 'unsigned int'. typedef   unsigned int           uInt; //--          Sign related constants           --// // PURPOSE: To tell how many bits to shift the sign field from the //   least...

  • (a) Suppose that i, X2,... , In is an i.i.d. sample from Exp(1). Show that, for...

    (a) Suppose that i, X2,... , In is an i.i.d. sample from Exp(1). Show that, for a standard normal random variable Z b) Show Г(n) by differencing both sides of the approximation in part a. Then set a -0 to get Stirling's Formula. 5. Suppose that Y is an id sample from Negative Binomial (n,p). Give a normal approximation of Yn use CLT, when n is large. 6. (Mandatory for Graduate Student. Extra credit for undergrad.) Let Ai, converges to...

  • course: Numerical analysis 3. Consider Rosenbrock's banane valley function f(x,y) = (x-1) + 100 (4-x², henceforth...

    course: Numerical analysis 3. Consider Rosenbrock's banane valley function f(x,y) = (x-1) + 100 (4-x², henceforth called the banana function. (a) Compute the gradient I f(x,y) of the banana function (6) Using (xo, Yo) = (-1.2, 1.0) as an initial point perform one iteration of the method of steepest, descent to explicitly find (X,Y). Refer to attached graph of level curves of the banana function. (XY)(-1.0301067/27..., 1.069344-19888...) and f(X,Y) S 401280972736-n, (c) Using (xoxo) = (-1-2, 1.0) as an initial...

  • 1 int i, j, k; 2 for (i = 1; i <= 4; i++) 3 {...

    1 int i, j, k; 2 for (i = 1; i <= 4; i++) 3 { 4 j = 1; 5 while (j < 4) 6 { 7 if (i % 2 == j % 2) 8 k = 100*i + 10*j; 9 else 10 k = 100*j + 10*i; 11 j++; 12 } 13 } What will be the value of the variable k at the end of the third, sixth, ninth, and twelfth iteration of the while loop

  • Show all steps of your solutions. Attach screen shots of your Logisim Solutions. Solutions without clear...

    Show all steps of your solutions. Attach screen shots of your Logisim Solutions. Solutions without clear solution steps will be subject to maximum penalty I. Assume that A 100 in hexadecimal and B = 25 in octal. Perform the indicated operations: a. A - B using 2's comp b. B- A using 10's comp 2. Write Institute of Electrical and Electronics Engineers (IEEE) floating point (32 bit) representation of the decimal number -100. 625 lement method lement method 3. Design...

  • 1. 2. 3. 4. (1 point) Eliminate the parametert to find a Cartesian equation for I=+2...

    1. 2. 3. 4. (1 point) Eliminate the parametert to find a Cartesian equation for I=+2 y= 10 + 2t 2 = Ay? + By+C where A= and B = and C = (1 point) Consider the parametric curve: 2 = 8 sin 0, y = 8 cos 0, 0<<A The curve is (part of) a circle and the cartesian equation has the form 2? + y2 = R2 with R= The initial point has coordinates: 3 = !!! ,y=...

  • I need help programming this question using C language. This program uses input data entered in...

    I need help programming this question using C language. This program uses input data entered in command line at the same time when the command or .exe file is entered. They are called command-line arguments. Because everything entered in command line is taken as a string, these arguments including the command itself or the .exe file name are stored in an array of char pointers, each pointer points to the first character of a string (i.e., argument). The inputs can...

  • question 1 part 2 and 3 thank you (47) Naruto Notone C Sign In er Sign...

    question 1 part 2 and 3 thank you (47) Naruto Notone C Sign In er Sign Up | Ch ® UFC & MMA × Secure I https://piazza-resourcess3.amazonaws.com/jgopch0cb93d8/j .pdfAWSAccessKeyld-AKAILDNRL/4ALKBWOHA8lexpires-15200435/2&Signature-ol9aXG9 /UAKIHS0QUwMeyBX.. ☆ ミ quations must be properly tyne-set including superscript-s expunents, Always watch the course websile for updates on the assignments. Question 1 (4 points) Show you work I. Convert 2727 into a 32-bit two's complement binary number 2. Convert -5795 into a 16-bit two's complement binary number 3. Add the above...

  • what is the answer for number 4 1. Let r(t) = -i-e2t j + (t? +...

    what is the answer for number 4 1. Let r(t) = -i-e2t j + (t? + 2t)k be the position of a particle moving in space. a. Find the particle's velocity, speed and direction at t = 0. Write the velocity as a product of speed and direction at this time. b. Find the parametric equation of the line tangent to the path of the particle at t = 0. 2. Find the integrals: a. S (tezi - 3sin(2t)j +...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT