Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Give the hexadecimal memory representation for real number 127.9375 that is stor

ID: 3632122 • Letter: G

Question

Give the hexadecimal memory representation for real number 127.9375 that
is stored in a single precision 32 bit floating point variable. Show
your work for each these steps.
i. Integer & Decimal/Fractional Portion Conversions
ii. Normalized Binary Representation for the Integer & Decimal
Portions Together
iii. Conversion from above to Sign, Exponent, Mantissa portions (1
bit, 8 bit, 23 bits respectively)
iv. Conversion from Binary to Hex

bonus question:
Examine the following code:
#include <stdio.h>
int main ( void ) {
float b = 33554433.0;
printf("%d ", b);
}
What value is printed and why? Assume a 32 bit single precision float.

Explanation / Answer

please rate - thanks

127.9375

The number is positive so the sign bit or most significant bit is 0

127 in binary is 1111111(I’m assuming you know how to do this)
to change .9375 to binary

Step 1: Begin with the decimal fraction and multiply by 2. The whole number part of the result is the first binary digit to the right of the point.

Because .9375= 1.875, the first binary digit to the right of the point is a 1.
So far, we have .9375=.1??? . . . (base 2) .

Step 2: Next we disregard the whole number part of the previous result (the 0 in this case) and multiply by 2 once again. The whole number part of this new result is the second binary digit to the right of the point. We will continue this process until we get a zero as our decimal part or until we recognize an infinite repeating pattern.

Because .875x 2 = 1.75, the second binary digit to the right of the point is a 1.
So far, we have .4375 = .11?? . . . (base 2) .

Step 3: Disregarding the whole number part of the previous result (we multiply by 2 once again. The whole number part of the result is now the next binary digit to the right of the point.

Because .75 x 2 = 1.5, the third binary digit to the right of the point is a 1.
So now we have .2 = .111?? . . . (base 2) .

One more time and we get that .9375 decimal is .1111 binary

so the binary number you are starting with is 1111111.1111

Using rules of scientific notation this can be changed to 1.1111111111x2^6



The exponent, which is in bits 30-23, will be 6 + 127 (we always add 127 to the exponent) or 133. 133 in binary is 10000101 this is 8 bits so no need to add any leading 0’s

The fraction or significand, which is in bits 22-0, is gotten by dropping the 1 from the 1.1111111111 above (we drop the 1 since the digit before the . will always be one ) and have 1111111111 less then the 23 bits needed. Therefore we add trailing 0’s. 11111111110000000000000



Therefore 127.9375 is 0 10000101 11111111110000000000000

or

42FFE000

extra credit

33554433.0

is represented in memory as 4C000000

and you cannot output a floating point number with a %d specification. %d is for integers only

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote