In this case, the floating values for 3e-1 and .3 are both "wrong," i.e. not really equal to mathematical .3, but since they have the same error, subtracting one from the other happens to return 0. So the result seems correct, but only because the two inaccuracies compensate each other.> perl5 -E 'say 3e-1 - .3' 0
Here, voluntarily or not, you mix up two different types. 3e-1 is a floating-point value (and, as such, liable to inaccuracies, as we all know), whereas .3 is a rational, and is entirely accurate.> perl6 -e 'say 3e-1 - .3' 5.55111512312578e-17
For example, printing the first 100 digits of .3 under Perl 6:
Subtracting a rational from an inaccurate float is just wrong, it is like adding apples and oranges.> printf "%.100f\n", .3; 0.30000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000 >
In reply to Re^6: Small Perl 6 discoveries II, Rats
by Laurent_R
in thread [Perl6] Small discoveries I, __DATA__
by holli
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |