Repository navigation
Compile a real remainder over double and float with one rounding - #2333
Merged
Rafael-SOWNet merged 1 commit intoNov 2, 2026
Merged
Conversation
The LINQ compiler wrote the floored remainder as ((a % b) + b) % b. Over the integers that is exact; over double the second % rounds even where the first remainder already had the divisor's sign. 2 mod e compiled to 1.9999999999999996, and floor(2 mod e) to 1, where both evaluate to 2. Over double and float the remainder is now taken once and the divisor added only where the signs differ, as RealOnly.Mod already did for Complex. The integer types keep the exact expression. Found by compilesweep at seed 11: pi / floor(2 mod e) compiled to pi. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2333 +/- ##
=======================================
Coverage 86.75% 86.76%
=======================================
Files 312 312
Lines 68447 68460 +13
Branches 19909 19913 +4
=======================================
+ Hits 59379 59396 +17
+ Misses 4908 4904 -4
Partials 4160 4160
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Rafael-SOWNet
deleted the
a-compiled-real-remainder-is-not-taken-twice
branch
November 2, 2026 16:51
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.
Found by compilesweep at seed 11, where
pi / floor(2 mod e)compiled topi. No issue was filed.The LINQ compiler wrote the floored remainder as
((a % b) + b) % b. Over the integers that is exact. Overdoublethe second%rounds, even where the first remainder already had the divisor's sign.double, 2.6.0 and master2 mod e=1.999999999999999622floor(2 mod e)=122Over
doubleandfloat, the remainder is now taken once, and the divisor is added only where the signs differ, asRealOnly.Modalready does forComplex. The integer types keep the exact expression.Tests: three of the seven in
ACompiledRealRemainderTestfail on master. The 1,191 compile tests pass. There is a BREAKING entry, A compiled remainder of two reals is rounded once.🤖 Generated with Claude Code