On Tue, Aug 02, 2016 at 10:55:34AM -0700, Zefram wrote:
> These literals work fine in other contexts:
> 
> > my $a = 1180591620717411303424e0
> 1.18059162071741e+21
> > my $b = 1180591620717409992704e0
> 1.18059162071741e+21
> > $a.Int
> 1180591620717411303424
> > $b.Int
> 1180591620717409992704
> > $a == $b
> False
> > $a === $b
> False

It's not universally true that Num literals like these "work fine in other 
contexts" -- the pair of literals in the example given "work" because they 
differ in the fifteenth decimal digit of precision.  This is within the 
acceptable norms for Num (floating point) precision.

Choosing a different pair of literal values that differ beyond the first 15 
digits of precision shows that things do not work fine in other contexts:

>  my $a = 1180591620717411303424e0
1.18059162071741e+21
>  my $b = 1180591620717411333333e0
1.18059162071741e+21
> $a.Int
1180591620717411303424
> $b.Int
1180591620717411303424
> $a == $b
True
> $a === $b
True

In short, it's "normal" (expected behavior) for mathematical errors to occur 
beyond 15 digits of precision in Num (floating point) values.

Pm

Reply via email to