Fred. Zwarts <
F.Zw...@kvi.nl> wrote:
> Op 07.jun..2019 om 20:56 schreef Christian Gollwitzer:
>> Am 07.06.19 um 15:51 schrieb Öö Tiib:
>> ... Floating point numbers are by
>> definition inaccurate, but this does not mean they are irreproducible.
>
> I think the term "inaccurate" is a bit inaccurate here. :-)
> Floating point calculations are very accurate, often more than integer
> calculations. But floating point calculations are more difficult to
> understand.
I think there's a bit of ambiguity about what is meant by "accuracy" here.
Pretty much all modern hardware implement the IEEE standard when dealing
with floating point values, and AFAIK that standard defines very
meticulously and unambiguously what the result of every operation must
be with given input values, bit-by-bit. If you know these definitions,
you know *exactly* what the result of an operation, with given values,
will be, to the last bit of it. There's no fuzziness here.
Also, "inaccuracy" may lead one to believe that the result might vary
randomly even with the same input. Obviously that's not the case. The
result will always be the same.
But here the term is most probably used with the meaning "you can't
represent the result of many operations completely exactly, and there
will often be rounding errors." As an example 1.0 and 3.0 can both be
represented with complete accuracy, but the result of 1.0/3.0 cannot,
and will have a small rounding error (because 1/3 is not representable
completely accurately with floating point).
However, one could think of it as no different than operations applied to
ints not being always representable. If, for example, you multiply two
ints, and the result is too large, the end result will not be accurate,
for the mere reason that the variable type doesn't have enough bits to
represent it accurately. This is no different from floating point: It, too,
doesn't have enough bits to represent every possible value accurately.
It's just that when people say "floating point is inaccurate", it's often
said with some kind of implication that integer variables do not suffer
from this same problem. Even though they do.
*All* mathematic operations done on computers is inaccurate in some cases
in one way or another. Pointing to floating point in particular is a bit
misleading.