I have a part of a problem that I don't fully understand. I got a nice explaination, but one part of the explaination I don't get.
Problem:
We can store only 5 bits in total and we round to the nearest, ties round to the nearest even digit.
example1. 1.1011100 becomes 1.1100 (up)
example2. 1.1010100 becomes 1.1010 (down)
My initial question was:
How becomes 1.1011100 --> 1.1100?
A class mate gave a nice explaination:
1.1011100 need to be rounded to something of 5 bits. For this, we look at the 5th and 6th bit 1.101(1)(1). This is a 1, so we round up to get an "even" number. 1.10111 rounded up is equal to 1.1100, and we only store 5 bits to the answer is. 1.1100. If the 5th bit was a 0 and the 6th bit was a 1, we would round down to get an even number.
I think the explaination is fine, but I lack the knowledge to fully understand it. What I made bold are the statements I don't understand.
My questions:
- Why do you round up if the 5th and 6th bits are a one?
- If the 5th bit was a 0 and the 6th bit was a 1 why would you round down to get an even number?
- Why does the position of the 4th bit(3th after the comma) move to the left in the round off?
Look at the tail of bits that is going to removed by the rounding. There are three cases:
If the tail starts with zero, round down. For example, the number 0.1001 011.. lies between 0.1001 and 0.1010 (which is what you get when adding one to the last digit of 0.1001), but lies closer to the lower number. Therefore it is rounded down to 0.1001.
If the tail starts with one, and there are further ones later in the tail, then round up. For example, the number 0.1001 101.. lies between 0.1001 and 0.1010, but lies closer to the higher number. Therefore it is rounded up to 0.1010.
If the tail starts with one and has only zeroes following it, then round up or down to make it end in zero. For example, the number 0.1001 1000 lies exactly midway between 0.1001 and 0.1010. The latter is the one that ends in zero (the only even digit in binary). Therefore it is rounded up to 0.1010.