Repository navigation
TSLANG_ISSUES 16: % of 64-bit integers is an integer remainder - #571
Merged
Merged
Conversation
`%` cast both operands to number (f64), so a u64 remainder was wrong once the value passed 2^53. When both operands are integers and one is 64-bit, `%` is now done in that type; narrower integers keep the number path, which is exact for them. The lowering took the signed remainder for the signless lowered operand, so an unsigned one now takes `remui`, as `>>` does since #556. `/` still gives a number, as in JavaScript. A 64-bit `x % 0` traps like integer division in C instead of giving NaN. Found reading the bytes of a u64 word (TSLANG_ISSUES.md 16). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ASDAlexander77
added a commit
that referenced
this pull request
Oct 13, 2026
13, 14, 15 and 18 are fixed by #572, #568, #570 and #569. For 16, `%` is fixed by #571 and `/` stays a number. 17 is answered (`Deref(p[i]) = v` stores) and its error names that form since #573. 5 and 6 stay open: they are design questions, not bugs. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
TSLANG_ISSUES.md 16:
u64 %went through f64 (wrong above 2^53).%of two integers, one of them 64-bit, is now done in that 64-bit type (the result type is that integer, notnumber). Narrower integers keep the number path, which is exact for them.%pickedremsifor unsigned too. It now takesremuifor an unsigned operand, like>>since Shifts and bitwise operators keep a 64-bit integer operand's width #556.Decisions to confirm:
/is unchanged: it still gives anumber, as in JavaScript, so there is still no exact 64-bit integer division.x % 0now traps (like integer division in C) instead of giving NaN.Test:
00int64_remainder.ts(u64 above 2^53,%=, all-ones u64, signed s64 takes the dividend's sign, s32/number unchanged).Full Release suite with all six TSLANG_ISSUES fixes together: 4074/4074.
🤖 Generated with Claude Code