"be consistent" | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Here's a short explanation of what happens. Recall that when a ratio of integers (a rational number) is shown in decimal form, the decimal fraction terminates only if the The same thing happens with n-al fractions in any base n. Processors represent floats in base two, so any rational fraction with a factor of 5 forms an infinite repeating pattern of ones and zeros. The processor can only hold a finite number of the leading bits, so the floating point representation of 182/5 == 36.2, 183/5 == 36.4, and 1/5 == 0.2 are all low-side approximations. When they are added and subtracted, the results are internally rounded from a few extra bits the processor keeps hidden, with the confounding result that floating-point addition is not even associative! After Compline, In reply to [Why] Re: float values and operators
by Zaxo
|
|