I am trying to convert 0.3 to IEEE754 format.
What I am getting is: 0011111010011001100110011001 1001
, but
what I should get is: 0011111010011001100110011001 1010
. As you can see, the last 4 digits differ. I multiplied 0.3 with 2 until I found the period and then, after filling the mantisa with 001, I filled the rest of the mantisa with the period (1001). What am I doing wrong?
You have to round, not truncate. At bit 25 the pattern continues: 10011001... Since bit 25 and beyond is > 1/2 ULP, you have to round up. That will give you the answer you are expecting.