correct safe integer range for bitwise ops#381
Merged
stephenamar-db merged 1 commit intomasterfrom May 14, 2025
Merged
Conversation
This was
linked to
issues
May 14, 2025
He-Pin
reviewed
May 15, 2025
| // Constants for safe double-to-int conversion | ||
| // IEEE 754 doubles precisely represent integers up to 2^53, beyond which precision is lost | ||
| private val DOUBLE_MAX_SAFE_INTEGER = (1L << 53) - 1 | ||
| private val DOUBLE_MIN_SAFE_INTEGER = -((1L << 53) - 1) |
Contributor
There was a problem hiding this comment.
It would be nice to have the same comments:
Integers can be safely represented as a Jsonnet number in the range [-2^53 + 1,2^53 - 1]. This is a direct consequence of IEEE754 spec, with the requirements that a safe integer is representable exactly, and cannot be produced by rounding any other integer to fit the IEEE-754 representation. See also, the JavaScript Number.MAX_SAFE_INTEGER, Number.MIN_SAFE_INTEGER, and Number.isSafeInteger definitions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #317 #316 #315