0
votes

I am trying to understand how to convert from decimal to IEEE-754 Single Precision binary representation.

I make up a random number which happen to be 601.00

I tried my best to figure it out and this is what I got:

Step 01: I divided 601 by 9 (since 2^9 is the largest power of 2 divisible by my number) so I got 66.7778

Step 02: I have for the exponent 9 + 127 = 136 which is 10001000 in binary. Step 03: The sign is 0

Right now the representation is: (missing the mantissa) 0 10001000

But what is the mantissa representation for 66.7778 in binary?

1
You might be interested in some C code converting strings containing decimal floating-point values into single and double precision IEEE-754 formats. Here.Alexey Frunze

1 Answers

3
votes

Step 1 should be: divide 601 by 2^9, not by 9.

To get the mantissa, subtract 1 from the result of the division and multiply it by 2^23. Express the integer part of the product in binary. You can (and should) collapse the two steps, so that you end up multiplying (601 - 2^9) * 2^14.