representing .1 in base(2)????

Started by
2 comments, last by fastcall22 13 years, 5 months ago
i understand it's impossible to represent .1 in base(2) but im curious as to WHY exactly?? i know you can keep getting closer and closer to it the further you go into the negative powers of 2, but im wondering what the real reasoning is why you cannot reach it?
Advertisement
For the same reason you get repeating decimals in decimal arithmetic: eventually the remainder after factoring out a digit repeats. For example, to do the long division in decimal arithmetic for 50/74:
         0.675   74 ) 50.0        44.4          560          518           420           370            500

The initial remainder is the full 50. Subtracting .6 times 74 leaves 5.60. Subtracting .07 times 74 leaves .420. Subtracting 0.005 times 74 leaves 0.050. Now we have a remainder that is the same as the initial value multiplied by a power of 10 from the original. That means we keep repeating the same digits over and over again. Another 6, then another 7, then another 5, until infinity. The same thing happens in binary.
Quote:what the real reasoning is why you cannot reach it?

Because 0.1base10 is not evenly divisable by any inverse power of 2. No matter what small inverse power of 2 you choose, it will not divide into 0.1base10 an exact integer number of times.

E.g., in base 10 (using SiCrane's example), 0.675base10 means six-hundred and seventy-five 1/1000ths, exactly. It can be expressed that way because 0.675 is divisable by 1/1000 without anything left over.

For 0.1base10, there is no equivalent expression for an integer multiple of any inverse power of 2.

EDIT: Perhaps a little more obvious - consider inverting 0.1 and it's binary equivalent.

1/0.1 = 1/binary-equiv

That equation becomes:

10 = some-integer-multiple-of-power-of-2

Simply can't be done.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Quote:Original post by nuclear123
i know you can keep getting closer and closer to it the further you go into the negative powers of 2, but im wondering what the real reasoning is why you cannot reach it?


There are only so many bits of precision you can fit into the mantissa. For a 16-bit float, Try out this applet. The mantissa for 0.1base10 is 1001 repeating... See also IEEE-754, Binary32, Binary64.

This topic is closed to new replies.

Advertisement