help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is 0.01 here not 0.01 here 0.009999999999999?


From: John Yates
Subject: Re: What is 0.01 here not 0.01 here 0.009999999999999?
Date: Fri, 2 Apr 2021 16:46:26 -0400

On Fri, Apr 2, 2021 at 1:07 PM Jean Louis <bugs@gnu.support> wrote:
> Thank you. I did browse it, did not yet understand it.

And so, having made no progress towards understanding
computer-based floating point arithmetic, you press on
arguing from a position of ignorance.

Put most simply, on a machine in which floating point
numbers encode the significand (sometimes erroneously
termed the 'mantissa') using a binary representation,
there is no way to encode, and hence express, a fraction
whose divisor is not a power of 2.  So you can encode
precisely 1/2, 1/4, 1/128, etc.  But you will never have a
precise encoding of 1/3, 1/5, 1/10, etc.

Much effort has gone into optimizing "round tripping",
the conversion of decimal numbers into the nearest
floating point number and getting it back out again.

But you are asking for more.  You want arithmetic on
imprecise representations of your perfect decimal
numbers to deliver precisely the same result as your
mental model.  That is never going to happen.

I am not going to try to explain normalization, rounding,
rounding modes, etc.  Suffice it to say that this is the
realm of numerical analysis, a rich field that traces its
roots straight back to Alen Turing.

In closing, let me recommend David Goldberg's classic
'What every computer scientist should know about
<http://pages.cs.wisc.edu/~david/courses/cs552/S12/handouts/goldberg-floating-point.pdf>
floating-poing arithmetic
<http://pages.cs.wisc.edu/~david/courses/cs552/S12/handouts/goldberg-floating-point.pdf>
'.

/john


reply via email to

[Prev in Thread] Current Thread [Next in Thread]