Skip Menu |
Report information

Subject: [BUG] Rat.perl doesn't round-trip numerical value
To: rakudobug [...] perl.org
From: Zefram <zefram [...] fysh.org>
Date: Fri, 18 Sep 2015 21:24:41 +0100
Download (untitled) / with headers
text/plain 320b
$ ./perl6 -e 'my $a = 0.89999999999999999999; my $b = $a.perl.EVAL; say $a.WHICH; say $b.WHICH' Rat|89999999999999999999/100000000000000000000 Rat|9/10 $a.perl is "0.9", which is not an accurate reflection of its true value. If the 8 digit is changed to 9, the .perl output is "0.A", which is even more bogus. -zefram
Download (untitled) / with headers
text/plain 767b
You've reported the wrong bug. The value you created shouldn't be a Rat at all. Show quoted text
> my $a = 0.89999999999999999999; ([/] $a.nude).WHAT.say
(Num) Show quoted text
> $a.denominator > $UINT64_UPPER;
True So this ticket (and #126016) are fallout from the fact that the distinction between Rat and FatRat is only partially implemented. See http://design.perl6.org/S02.html#Numeric_Types On Fri Sep 18 13:24:54 2015, zefram@fysh.org wrote: Show quoted text
> $ ./perl6 -e 'my $a = 0.89999999999999999999; my $b = $a.perl.EVAL; > say $a.WHICH; say $b.WHICH' > Rat|89999999999999999999/100000000000000000000 > Rat|9/10 > > $a.perl is "0.9", which is not an accurate reflection of its true > value. > If the 8 digit is changed to 9, the .perl output is "0.A", which is > even > more bogus. > > -zefram
OK, there are two problems mentioned in the report. The second one (with 0.A being created) is part of RT#126016 which is now resolved. ✓

As for the other issue, the behavior has changed a little bit:


my $a = 0.89999999999999999999; my $b = $a.perl.EVAL; say $a.WHICH; say $b.WHICH

¦c8ec2999bee^:
«Rat|89999999999999999999/100000000000000000000␤Rat|9/10␤»

¦c8ec299,HEAD(5929887):
«Rat|89999999999999999999/100000000000000000000␤Rat|89999999999999999999/100000000000000000000␤»

The commit in question is (2015-09-25) https://github.com/rakudo/rakudo/commit/c8ec2999bee8b2396419d9ebf54e5e2656a6c0b8


As already mentioned, the problem is a little bit different. Rats with too big denoms are weird, and there's a ticket for that: RT#132313

I'll interlink the tickets and leave this open.

On 2015-09-19 00:28:52, labster wrote:
Show quoted text
> You've reported the wrong bug. The value you created shouldn't be a
> Rat at all.
>
> > my $a = 0.89999999999999999999; ([/] $a.nude).WHAT.say
> (Num)
> > $a.denominator > $UINT64_UPPER;
> True
>
> So this ticket (and #126016) are fallout from the fact that the
> distinction between Rat and FatRat is only partially implemented. See
> http://design.perl6.org/S02.html#Numeric_Types
>
>
> On Fri Sep 18 13:24:54 2015, zefram@fysh.org wrote:
> > $ ./perl6 -e 'my $a = 0.89999999999999999999; my $b = $a.perl.EVAL;
> > say $a.WHICH; say $b.WHICH'
> > Rat|89999999999999999999/100000000000000000000
> > Rat|9/10
> >
> > $a.perl is "0.9", which is not an accurate reflection of its true
> > value.
> > If the 8 digit is changed to 9, the .perl output is "0.A", which is
> > even
> > more bogus.
> >
> > -zefram




This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org