Algorithm for Converting a base 10 number to the IEEE floating point

Algorithm for Converting a base 10 number to the IEEE floating point representation. (Disclaimer: this
is only one of many possible algorithms.) We will use the following base 10 number as an example:
-9.625
Step 1: Convert the absolute value of the number to an unsigned binary representation.
9.625 (base 10) = 1001.101 (binary)
Step 2: Express the binary number in normalized scientific notation.
1001.101 x 20 = 1.001101 x 23
fractional portion
Step 3: Enter the fractional portion of the number above in the fraction field of the floating pt
representation.
-
--------
sign exponent
0011010000000000000000
fraction
Step 4: Add the bias to the exponent and express the result as an 8-bit unsigned binary number.
3+127 = 130
bias
130 (base 10) = 10000010 (binary)
Step 5: Enter the exponent calculated above in the exponent field of the floating pt representation.
- 10000010 0011010000000000000000
sign exponent
fraction
Step 6: Enter the sign bit in the sign field of the floating pt representation; enter 1 if the number is
negative, and 0 if the number is positive.
1 10000010 0011010000000000000000 the answer
sign exponent
fraction