for / while else doesn't make sense

Ian Kelly ian.g.kelly at gmail.com
Mon May 23 15:24:30 EDT 2016


On Mon, May 23, 2016 at 12:16 PM, Pete Forman <petef4+usenet at gmail.com> wrote:
> Something else which I do not think has been stated yet in this thread
> is that floating point is an inexact representation. Just because
> integers and binary fractions have an exact correspondence we ought not
> to be affording them special significance. Floating point 1 is not the
> integer 1, it stands for a range of numbers some fraction either side of
> 1.

This is not the case. Floating point 1 means exactly 1, no more and no
less. Results that aren't exactly representable get rounded to values
that are, but this does not imply that the value once rounded is
inexact. The value that 1/3 gets rounded to is exactly equal to
6004799503160661 / 18014398509481984, no more and no less.

Treating floating point values as inexact would require an
accumulation of the range of error. Otherwise, it would no longer be
correct to say that 1.0 * 1.0 == 1.0. The result could with equal
correctness be the next floating point number after 1.0, or the
previous value before 1.0. Continue multiplying by 1.0 and the error
creeps larger and larger. The defined result of the operation,
however, is the exact value 1.0.



More information about the Python-list mailing list