Are you trolling or what?
Here Perl6 is 1000 times more accurate, it's just not lying to you about being arbitrarily precise. You will notice that 1.11111111111111 is three digits shorter than 1.11111111111111111 !
And also:
holli@605 ~ $ perl -e 'say "oops" unless 0.1 + 0.2 == 0.3'
oops
holli@605 ~ $ perl6 -e 'say "yeah" if 0.1 + 0.2 == 0.3'
yeah
holli
You can lead your users to water, but alas, you cannot drown them.
| [reply] [d/l] |
> perl5 -E 'say 3e-1 - .3'
0
> perl6 -e 'say 3e-1 - .3'
5.55111512312578e-17
| [reply] [d/l] |
> perl5 -E 'say 3e-1 - .3'
0
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.
> perl6 -e 'say 3e-1 - .3'
5.55111512312578e-17
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.
For example, printing the first 100 digits of .3 under Perl 6:
> printf "%.100f\n", .3;
0.30000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000
>
Subtracting a rational from an inaccurate float is just wrong, it is like adding apples and oranges.
| [reply] [d/l] [select] |
why does perl6 print all those wrong digits?
There is a well-hidden message in the "wrong" digits. Click here and follow the links.
Alexander
--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
| [reply] |
> 111111111111111111111/1000000000000000000000
0.111111111111111
> .111111111111111111111
0.11111111111111111604544
| [reply] [d/l] |
| [reply] |