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

Can't represent Num literals close to the representable maximum in Rakudo #5784

Closed
p6rt opened this issue Nov 7, 2016 · 4 comments
Closed
Labels

Comments

@p6rt
Copy link

p6rt commented Nov 7, 2016

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

Searchable as RT130039$

@p6rt
Copy link
Author

p6rt commented Nov 7, 2016

From @masak

<MARTIMM> Wondering what the highest number is below Inf and lowest above -Inf
<masak> MARTIMM​: for the Num type, there's a highest representable
number below Inf
<masak> m​: say 1e308
<camelia> rakudo-moar 1c425f​: OUTPUT«1e+308␤»
<masak> this is the largest Num below Inf I can get Rakudo to represent.
<geekosaur> 1.7976931348623157081e+308 on x86_64
<geekosaur> (and probably x86)
<masak> I expected it to be something like that, but the cutoff in
Rakudo was at exactly 1.000e308
<masak> maybe some artificial limit has been put in somewhere for safety reasons
<masak> m​: say 1.7976931348623157081e200 * 1e108
<camelia> rakudo-moar 1c425f​: OUTPUT«1.79769313486232e+308␤»
<masak> a-ha :)
<masak> so Rakudo can represent them, just not with
scientific-notation number literals
<masak> I... would be tempted to call that a bug.
* masak submits rakudobug

@p6rt
Copy link
Author

p6rt commented Nov 8, 2016

From @zoffixznet

On Mon, 07 Nov 2016 03​:50​:49 -0800, masak wrote​:

<MARTIMM> Wondering what the highest number is below Inf and lowest
above -Inf
<masak> MARTIMM​: for the Num type, there's a highest representable
number below Inf
<masak> m​: say 1e308
<camelia> rakudo-moar 1c425f​: OUTPUT«1e+308␤»
<masak> this is the largest Num below Inf I can get Rakudo to
represent.
<geekosaur> 1.7976931348623157081e+308 on x86_64
<geekosaur> (and probably x86)
<masak> I expected it to be something like that, but the cutoff in
Rakudo was at exactly 1.000e308
<masak> maybe some artificial limit has been put in somewhere for
safety reasons
<masak> m​: say 1.7976931348623157081e200 * 1e108
<camelia> rakudo-moar 1c425f​: OUTPUT«1.79769313486232e+308␤»
<masak> a-ha :)
<masak> so Rakudo can represent them, just not with
scientific-notation number literals
<masak> I... would be tempted to call that a bug.
* masak submits rakudobug

The issue was due to calculations involved during the number's parsing, where the base
value was first multiplied by enough powers of 10 to make it fraction-less and then
multiplied by "e" powers of 10. For numbers close to the limit, this caused overflow to
Inf before the final step (of dividing the number back) could be done.

So 1.1e307 overflown, 1.1e306 wouldn't, but 1.11e306 would, because 1.11 was turned into 111 in mid-step.

Fixed in rakudo/rakudo@​729d7e34124827a4e0b772b049be95cf911dd7cf
Tests added in https://rt.perl.org/Public/Bug/Display.html?id=130039

@p6rt
Copy link
Author

p6rt commented Nov 8, 2016

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

@p6rt
Copy link
Author

p6rt commented Nov 8, 2016

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

@p6rt p6rt closed this as completed Nov 8, 2016
@p6rt p6rt added the Bug 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