in reply to Integers sometimes turn into Reals after substraction
But 4/25 isn't a number which can be accurately represented in a binary system and rounding errors come into play.
See also Humans have too many fingers
To elaborate further
(4*1000)/25 is an integer but 1000*(4/25) is a float with a very tiny error in the last bits of the mantissa.
Perl will still print this float like an integer because the error is too small.
But after the subtraction the leading zeros in the mantissa will cause a left shift (with adjustment of the exponent).
This means the error shifts out of Perl's tolerance margin and is printed as (decimal) fraction.
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
|
---|