develooper Front page | perl.perl6.compiler | Postings from April 2018

[perl #128820] [BUG] == on Num literals produces bogus answer

Thread Previous | Thread Next
From:
Zoffix Znet via RT
Date:
April 13, 2018 10:31
Subject:
[perl #128820] [BUG] == on Num literals produces bogus answer
Message ID:
rt-4.0.24-24193-1523615500-119.128820-15-0@perl.org
On Tue, 02 Aug 2016 10:55:34 -0700, zefram@fysh.org wrote:
> > 1180591620717411303424e0 == 1180591620717409992704e0
> True
> > 1180591620717411303424e0 === 1180591620717409992704e0
> True
> 
> Say what?  These are distinct Num values, differing by 10 ulp.
> 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
> 
> == and === give the right result when applied to $a and $b as here, or
> when applied to declared constants ("constant \A = 118...").  They also
> work fine when comparing a variable against a literal.  They go wrong when
> applied directly to two literal expressions.  They also go wrong with some
> more complex expressions that bring in both values as literals, such as if
> both sides are multiplied by 1.0e0 or by a variable containing that value.
> 
> -zefram

Thank you for the report. This is now fixed.

Fix:  https://github.com/MoarVM/MoarVM/commit/067c0594103a025
      https://github.com/MoarVM/MoarVM/commit/8841c4241b4faa8
      https://github.com/MoarVM/MoarVM/commit/af2eb8a7f7d4344
      https://github.com/MoarVM/MoarVM/commit/4d3fc2818d0032b
      https://github.com/rakudo/rakudo/commit/8422d7b4e23678b
      https://github.com/rakudo/rakudo/commit/a2a2a745c4242d1
Test: https://github.com/perl6/roast/commit/52c60ce5c283dd5b8
      https://github.com/perl6/roast/commit/bba5e9fdda431c9f4

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About