for / while else doesn't make sense

Pete Forman petef4+usenet at gmail.com
Mon May 23 17:50:46 EDT 2016


Ian Kelly <ian.g.kelly at gmail.com> writes:

> 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.

Let us for the sake of argument consider a floating point representation
that has one decimal point of precision. It is easier to talk about than
the IEEE double precision used in Python.

If you are talking about the multiplicative identity element then 1.0 is
exactly unity and repeated multiplication will not change the result.
However I am coming from scientific measurements where 1.0 is the stored
value for observations between 0.95 and 1.05. If I wish to correlate two
signals that were 1.03 and 1.04 at higher precision then 1.1 is actually
a reasonable value for their "correct" product, even though 1.0 is what
is prescribed by IEEE-style rules because they are both stored as 1.0.

I agree that errors tend to creep ever larger. IEEE rounding rules seek
to minimize the error of the result but management of the accumulated
error is up to the scientist / programmer, it is not part of the IEEE
arithmetic.

-- 
Pete Forman



More information about the Python-list mailing list