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

NQP converts large integers to floats when it shouldn't/doesn't need to #363

Closed
coke opened this issue May 29, 2017 · 3 comments · Fixed by #518
Closed

NQP converts large integers to floats when it shouldn't/doesn't need to #363

coke opened this issue May 29, 2017 · 3 comments · Fixed by #518

Comments

@coke
Copy link
Contributor

coke commented May 29, 2017

Originally posted in https://rt.perl.org/Ticket/Display.html?id=131385 by ddgreen @ gmail.com

So `nqp-m -e 'say(100000000000000009)'` prints `100000000000000016`.

See https://irclog.perlgeek.de/perl6-dev/2017-05-27#i_14646898 for some discussion with jnthn.

zoffixznet added a commit to rakudo/rakudo that referenced this issue Aug 1, 2018
Fixes R#2157 #2157

The cause of the bug is NQP apparently uses doubles to handle its
ints[^1]. 2**52 is the limit under which every number is representable
in a double, which is why when we bumped up[^2] the point at which we
switched to bigints in Rakudo to be over that limit, we brought in the
NQP's limitation into Perl 6 land.

Fix by dialing down the switch to bigint to occur before we go over the
2**52 limit. The NQP Issue[^1] will resolve the problem in NQP land and
once that's done, I presume we can bump up the limit in rakudo once again.

[1] N#363 Raku/nqp#363
[2] b61b3c7
@zoffixznet
Copy link
Contributor

zoffixznet commented Aug 1, 2018

FWIW, this problem had impacted Perl 6 numerics too (R#2157)

In rakudo/rakudo@fec1bd74f9 and rakudo/rakudo@8e2c70fa15, I avoided that issue by going under the 2**52 limit under which every integer is representable in double.

Once this issue is fixed, I think we can bump up that limit in Rakudo again.

@tisonkun
Copy link
Member

tisonkun commented Aug 2, 2018

FYI,

nqp -e 'say(0x100000000000000009)' prints `9`

is it relevant?

@tisonkun
Copy link
Member

tisonkun commented Aug 2, 2018

Here might be code snip

https://github.com/MoarVM/MoarVM/blob/4d9829c061d35646d045a1d90d27337b3471b89d/src/core/coerce.c#L349-L420

could we auto-detect if we need bigint instead of int in nqp::radix?

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

Successfully merging a pull request may close this issue.

3 participants