# Floating-point rounding - bit patterns of values that are halfway between two possible results

I am working through the book Computer Systems: A Programmer's Perspective.

The authors explain that round-to-even rounding can be applied for values that are halfway between two possible results. For example, $$10.11100_2$$ would be rounded up to $$11.00_2$$ and $$10.10100_2$$ would be rounded down to $$10.10_2$$.

In general, they state that only bit patterns of the form $$XX...XX...Y100...$$, where $$X$$ denotes arbitrary bit values and $$Y$$ being the rightmost position to which we round, denote values that are halfway between two possible results.

Could someone explain to me why this is the case?

Thanks!

Let us express any given binary number without a floating point in the following form $$\underbrace{XX\cdots X}_{i\text{ digits}}~Y~\underbrace{ZZ\cdots Z}_{j\text{ digits}}{}_2=x\times2^{j+1} + Y\times2^j+z$$ where $$X$$ denotes arbitrary bit values and $$Y$$ being the rightmost position to which we round. $$x$$ is the number that corresponds to the first $$i$$ digits and $$z$$ is the number that corresponds to the last j digits.
Then two possible results are $$x\times2^{j+1} + Y\times2^j\quad \text{for round-down}$$ $$x\times2^{j+1} + (Y+1)\times2^j\quad\text{for round-up}$$ The average of two possible results, i.e., the number that is half way between them is $$x\times2^{j+1} + Y\times2^j+2^{j-1}$$ which is $$\underbrace{XX\cdots X}_{i\text{ digits}}~Y1~\underbrace{00\cdots 00}_{j-1\ 0\text{s}}{}_2$$