The usual mathematical answer.
Understanding that a floating point number is implemented as some bits representing the exponent, and the rest, mainly for digits (in the binary system), has the following situation:
With a high figure, say 10²³, if the least significant bit changes, a big difference appears between two adjacent distinghuishable numbers. In addition, the ten-digit base point 2 makes many base numbers 10 only approximate; 1/5, 1/10 - infinite numbers.
In the general case: floating point numbers should not be used if you need signed digits. For monetary amounts with calculations, e, a, it is best to use BigDecimal .
For floating point physics doubles are adequate, floats almost never. In addition, the floating point part of the processors, the FPU, may even use a little more precession internally.
Joop Eggen Nov 24 '12 at 16:30 2012-11-24 16:30
source share