Skip to content

TSLANG_ISSUES 16: % of 64-bit integers is an integer remainder - #571

Merged
ASDAlexander77 merged 1 commit into
mainfrom
fix-u64-remainder
Oct 13, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
fix-u64-remainder

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

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, not number). Narrower integers keep the number path, which is exact for them.
  • Lowering: the operand is signless after type conversion, so % picked remsi for unsigned too. It now takes remui for 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 a number, as in JavaScript, so there is still no exact 64-bit integer division.
  • A 64-bit x % 0 now 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

`%` 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>
@ASDAlexander77
ASDAlexander77 merged commit 965d4db into main Oct 13, 2026
2 of 3 checks passed
@ASDAlexander77
ASDAlexander77 deleted the fix-u64-remainder branch October 13, 2026 17:29
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.

1 participant