On Fri, 20 Oct 2017 07:34:04 -0700, [email protected] wrote:
> How to reproduce
> ----------------
>
> perl6 -e 'my ($a, $b) = (0.777777777777777777777,
> 0.7777777777777777777771); say $a <=> $b, " ", Num($a) <=> Num($b)'
>
> Expected behavior
> -----------------
>
> Prints `Less Less`, or `Less Same`, depending on how rounding is done.
>
> Actual behavior
> ---------------
>
> Prints `Less More`. This seems inconsistent: $a is strictly smaller
> than $b, yet Num($a) is strictly larger than Num($b).
>
> Version information
> -------------------
>
> This is Rakudo version 2017.09 built on MoarVM version 2017.09.1
> implementing Perl 6.c.
>
> This may be related to https://rt.perl.org/Public/Bug/Display.html?id=132313
This appears to be not a bug but simply the goodness of floating point math. I
get the same result in C:
#include <stdio.h>
int main(void) {
puts( 777777777777777777777.0L/1000000000000000000000.0L
> 7777777777777777777771.0L/10000000000000000000000.0L
? "More" : "Less or Same");
return 0;
}
// OUTPUT: More