Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.lotsof9s badly approximated #4549

Closed
p6rt opened this issue Sep 18, 2015 · 5 comments
Closed

0.lotsof9s badly approximated #4549

p6rt opened this issue Sep 18, 2015 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Sep 18, 2015

Migrated from rt.perl.org#126101 (status was 'resolved')

Searchable as RT126101$

@p6rt
Copy link
Author

p6rt commented Sep 18, 2015

From zefram@fysh.org

$ ./perl6 -e 'my $a = 0.99999999999999999999999; say $a; say $a.WHICH; say $a > 1'
1.000000000000000083886070
Rat|99999999999999999999999/99999999999999991611392
True

The Rat that is generated from this literal is a pretty poor approximation
of the value that it appears to represent. 1/1 would have been a
better approximation, if it's not acceptable to handle it exactly.
Adding more 9s to the literal produces a variety of approximated Rats,
of varying quality, some above 1 and some below.

-zefram

@p6rt
Copy link
Author

p6rt commented Oct 2, 2017

From @AlexDaniel

I think this is already fixed in rakudo/rakudo@f6e25b5

¦f6e25b54ea18ba7bd7d78^​:
1.000000000000000083886070
Rat|99999999999999999999999/99999999999999991611392
True

¦f6e25b54ea18ba7bd7d78​:
1
Rat|99999999999999999999999/100000000000000000000000
False

Maybe tests this were already added in https://rt-archive.perl.org/perl6/Ticket/Display.html?id=130845 , but I'll mark it as TESTNEEDED just in case.

On 2015-09-18 12​:45​:27, zefram@​fysh.org wrote​:

$ ./perl6 -e 'my $a = 0.99999999999999999999999; say $a; say $a.WHICH;
say $a > 1'
1.000000000000000083886070
Rat|99999999999999999999999/99999999999999991611392
True

The Rat that is generated from this literal is a pretty poor
approximation
of the value that it appears to represent. 1/1 would have been a
better approximation, if it's not acceptable to handle it exactly.
Adding more 9s to the literal produces a variety of approximated Rats,
of varying quality, some above 1 and some below.

-zefram

@p6rt
Copy link
Author

p6rt commented Oct 2, 2017

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Oct 7, 2017

From @moritz

Added another test here​: Raku/roast@a0b678199c

@p6rt
Copy link
Author

p6rt commented Oct 7, 2017

@moritz - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant