Well Perl's error correction (or that of the underlying C lib) is better than it's reputation
DB<186> $x1= 1000*(4/25) => 160 DB<187> $x2= 4000/25 => 160 DB<188> $x1 == $x2 => 1

What's puzzling me is this behaviour:

DB<205> for (254..263) {$x = 1000 * ( $_ + 4/25 ); printf "%.20f\n" +, $x} 254160.00000000000000000000 255160.00000000000000000000 256160.00000000002910383046 257160.00000000002910383046 258160.00000000002910383046 259160.00000000002910383046 260160.00000000002910383046 261160.00000000002910383046 262160.00000000000000000000 263160.00000000000000000000

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

update

interestingly this only seems to happen near some powers of 2

DB<220> for (0..20) {$e=2**$_; $x = 1000 * ( $e + 4/25 ); printf "$ +_:$e => %.20f\n", $x if ($x-int($x))} 5:32 => 32159.99999999999636202119 8:256 => 256160.00000000002910383046 9:512 => 512159.99999999994179233909 10:1024 => 1024160.00000000011641532183 11:2048 => 2048159.99999999976716935635 15:32768 => 32768160.00000000372529029846 18:262144 => 262144159.99999997019767761230 19:524288 => 524288160.00000005960464477539 20:1048576 => 1048576159.99999988079071044922

update

in hindsight this may be an effect of precision and correction of the underlying processor and usage of arithmetic units, hence machine dependent.


In reply to Re^2: Integers sometimes turn into Reals after substraction (error correction ?) by LanX
in thread Integers sometimes turn into Reals after substraction by rduke15

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":