Skip to content

Fix rem zero divisors and signed zshr results - #60

Merged
thomashoneyman merged 2 commits into
masterfrom
fix-rem-zshr-int-results
Nov 12, 2026
Merged

thomashoneyman merged 2 commits into
masterfrom
fix-rem-zshr-int-results

Conversation

@thomashoneyman

@thomashoneyman thomashoneyman commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Fixes #58 and addresses the library portion of #59.

When its divisor is zero Data.Int.rem returns NaN, despite the Int return type; this behavior differs from quot and Prelude's mod. To bring it in line this PR coerces the result with | 0`.

I applied the same to Data.Int.Bits.zshr. This is a behavioral change because shifting a negative input by zero or a multiple of 32 now returns the original signed input, instead of returning an unsigned number.

The zshr fix won't work without an accompanying compiler change because purs inlines direct calls as raw >>>, bypassing this library implementation altogether; so both the library and compiler fix are needed to fully resolve #59.

thomashoneyman and others added 2 commits November 9, 2026 01:41
Update bugfixes section with new issue references and clarify behavior changes.
@thomashoneyman
thomashoneyman merged commit c4d7815 into master Nov 12, 2026
1 check passed
@thomashoneyman
thomashoneyman deleted the fix-rem-zshr-int-results branch November 12, 2026 02:05
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.

Data.Int.Bits.zshr returns values outside the 32-bit signed Int range Data.Int.rem returns NaN instead of 0 when dividing by zero

2 participants