Repository navigation
fix: support full 64-bit integer range for number inputs in uint64/ctor - #15476
Conversation
Coverage Report
The above coverage report was generated for the changes in this PR. |
Co-authored-by: Athan <kgryte@gmail.com> Signed-off-by: Athan <kgryte@gmail.com>
|
|
||
| for ( i = 0; i < values.length; i++ ) { | ||
| z = values[i]; | ||
| z = BigInt( values[i] ); |
There was a problem hiding this comment.
Not clear why this change is necessary, but I'll defer to your judgment.
There was a problem hiding this comment.
Because calling toString on an unsafe integer truncates the trailing digits to zero even though those digits are exactly representable in double, which we can see with toPrecision. But there's no way to use toPrecision with arbitrary radix, so we need rely on BigInt for precise serialization with specified radix in this test.

There was a problem hiding this comment.
I feel like #.toString behavior is odd here and a likely source of confusion, especially when used in the REPL. Maybe we should add a dedicated utility to number/float64/to-exact-string (name?) to provide something more robust.
There was a problem hiding this comment.
After a bit of back-and-forth with ChatGPT, I understand why #.toString behaves as it does (namely, serialize to the shortest representation which generates the exact same double). But, for usage in the REPL, this can lead to misleading results.
Signed-off-by: Athan <kgryte@gmail.com>
Resolves none.
Description
This pull request:
Uint64constructor to allow unsafe integers upto2^64-1.Related Issues
No.
Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
N/A.
@stdlib-js/reviewers