I am listening to an operating system course in college, and we recently learned how floating point numbers are represented in memory.
Our homework is devoted to floatmanually converting floating-point numbers ( s) into their binary representations.
eg. 200,0234375would give 01000011010010000000011000000000after a long conversion process.
One question is about how 0.1f will be represented in memory. So I did the whole conversion process, and I ended up with this:
00111101110011001100110011001100
With what we have learned so far, this is the correct answer to the question (I asked the teacher).
But in the next question, we will be asked to check the answer with the program to see the actual binary representation of 0.1f. The real view is this:
00111101110011001100110011001101
(Pay attention to the last bit)
Then we will be asked to find out why this is happening.
I noticed a periodic one 0011when converting the number, and since the next bit after the final one 0will be 1, I would suggest that the computer will bypass this final one 0
before 1, which explains the difference.
So what I want to know, right? Is the computer rounding the last bit based on the next bit when 23 bits of the mantissa are used?
This is homework, so if you could just lead me to an answer, if I am wrong, I would appreciate it.
Also, I couldn’t find the answer to my question on Google for keywords I could think of. Forgive me if this is a duplicate.