Skip to content

Reduce safe integer range to exclude +/- 2^53 and match JavaScript safe-integer bounds #1240

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

johnbartholomew
Copy link
Collaborator

As noted in #1217 (comment) and discussed in #1238.

Although 2^53 is representable (there is a bit-pattern for a IEEE-754 double precision float which represents this value), it is not safe because as @CertainLach pointed out, it is ambiguous/not distinguishable from 2^53+1 which is not representable and would be rounded down.

This also switches from a StaticError to a RuntimeError when encounting a non-integer-safe value since these values are runtime constructs not parse time (static).

@CertainLach if you have time to review, I'd appreciate it.

Fixes #1238.

Copy link
Contributor

@CertainLach CertainLach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (I misunderstood the test twice initially)

@johnbartholomew
Copy link
Collaborator Author

LGTM (I misunderstood the test twice initially)

That sounds like the tests need some more work. I'll see if I can improve it before merging.

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 this pull request may close these issues.

BUG: Defined safe integer range is invalid
3 participants