Le 06/03/2018 à 05:48, A Z a écrit :
> Citation about problems with Java floating point:
This paper is about complex numbers, operation overloading, handling of
NaN, /etc./ I don't think that they are making an argument for decimal
> People absolutely need decimal accuracy, and not floating point
Float and double are accurate in base 2, which is as good as base 10 for
scientific and engineering applications (nature does not have a
preferred base - our use of base 10 is only because human have 10
fingers). Base 10 is useful in some cases like financial applications,
but those ones already have their own representation (e.g. integer count
of 1/1000 of cents). When numbers are measurements, values like 0.1 are
approximation anyway, no matter if using base 2 or base 10.
IEEE754 float and double types have hardward acceleration in modern CPU.
Consequently IEEE754 is used not only in Java, but also in other
languages like C/C++. The C language may give an impression of accuracy
because printf can round the last digits, but the actual accuracy is
still the same than Java.