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

Rat.Str incorrectly rounds in the part after the decimal dot #4524

Closed
p6rt opened this issue Sep 8, 2015 · 6 comments
Closed

Rat.Str incorrectly rounds in the part after the decimal dot #4524

p6rt opened this issue Sep 8, 2015 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 8, 2015

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

Searchable as RT126016$

@p6rt
Copy link
Author

p6rt commented Sep 8, 2015

From @moritz

14​:16 < moritz> m​: say 0.9999999999999999999999.Str
14​:16 <+camelia> rakudo-moar cbf85b​: OUTPUT«0.10␤»

Clearly this is wrong. If the intent is to round up, it should produce
1.0, not 0.10.

The Rat object itself is constructed correctly​:

14​:16 < moritz> m​: say 0.9999999999999999999999.nude
14​:16 <+camelia> rakudo-moar cbf85b​: OUTPUT«(9999999999999999999999
  10000000000000000000000)␤»

@p6rt
Copy link
Author

p6rt commented Sep 18, 2015

From zefram@fysh.org

The same Rat gets a different wrong output from .perl​:

$ ./perl6 -e 'say 0.9999999999999999999999.perl'
0.A

This too is rounding the first decimal place to ten, but expressing the
ten in a different way. (But really .perl shouldn't be rounding it at
all, in the interests of round-tripping.)

-zefram

@p6rt
Copy link
Author

p6rt commented Sep 18, 2015

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

@p6rt
Copy link
Author

p6rt commented Nov 18, 2016

From @zoffixznet

Same issue exists with base​:

<ZoffixW> m​: say 0.9999999999999999999999.base​: 10
<camelia> rakudo-moar b4592c​: OUTPUT«0.A␤»

@p6rt
Copy link
Author

p6rt commented Nov 18, 2016

From @zoffixznet

On Tue, 08 Sep 2015 05​:22​:21 -0700, moritz.lenz@​gmail.com wrote​:

14​:16 < moritz> m​: say 0.9999999999999999999999.Str
14​:16 <+camelia> rakudo-moar cbf85b​: OUTPUT«0.10␤»

Clearly this is wrong. If the intent is to round up, it should produce
1.0, not 0.10.

The Rat object itself is constructed correctly​:

14​:16 < moritz> m​: say 0.9999999999999999999999.nude
14​:16 <+camelia> rakudo-moar cbf85b​: OUTPUT«(9999999999999999999999
10000000000000000000000)␤»

Thanks for the report.
Fixed in rakudo/rakudo@b5aa3c5
Tests in Raku/roast@b1a305a489

PS.​: the .perl not roundtripping correctly was fixed as well in the above commit.

@p6rt
Copy link
Author

p6rt commented Nov 18, 2016

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

@p6rt p6rt closed this as completed Nov 18, 2016
@p6rt p6rt added the math label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant