4 hundred quadrillonth?
andreengels at gmail.com
Fri May 22 02:31:21 EDT 2009
On Thu, May 21, 2009 at 11:05 PM, <seanm.py at gmail.com> wrote:
> The explaination in my introductory Python book is not very
> satisfying, and I am hoping someone can explain the following to me:
>>>> 4 / 5.0
> 4 / 5.0 is 0.8. No more, no less. So what's up with that 4 at the end.
> It bothers me.
Well, how much would 1 / 3.0 be? Maybe 0.3333333333... with a certain
(large) number of threes? And if you multiply that by 3, will it be
1.0 again? No, because you cannot represent 1/3.0 as a precise decimal
Internally, what is used are not decimal but binary fractions. And as
a binary fraction, 4/5.0 is just as impossible to represent as 1/3.0
is (1/3.0 = 0.0101010101... and 4/5.0 = 0.110011001100... to be
exact). So 4 / 5.0 gives you the binary fraction of a certain
precision that is closest to 0.8. And apparently that is close to
André Engels, andreengels at gmail.com
More information about the Python-list