Repository navigation
A compiled remainder of two integers by zero has no value - #2328
Merged
Merged
Conversation
The LINQ compiler keeps the remainder of two integers over the integers, so
that it stays exact, and the runtime's % throws for a divisor of 0. Over
double or Complex, integer operands are constants, so 2 mod 0, or
abs(2) mod (2 mod (-1)), threw DivideByZeroException when the compiled
function was called. Where the divisor is a constant that evaluates to 0 the
node is NaN, as evaluation and FastExpression answer. A divisor in x is
compiled over double already, where % by 0 is NaN.
"x + (2 mod 0)".Compile<double, double>("x")(1): DivideByZeroException ->
NaN. 2.6.0 threw over Complex too, which master already answers.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2328 +/- ##
=======================================
Coverage 86.74% 86.75%
=======================================
Files 312 312
Lines 68439 68447 +8
Branches 19907 19909 +2
=======================================
+ Hits 59369 59380 +11
+ Misses 4913 4908 -5
- Partials 4157 4159 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
The LINQ compiler keeps the remainder of two integers over the integers, so that it stays exact, and the runtime's
%throws for a divisor of 0. OverdoubleorComplex, integer operands are constants. So2 mod 0, orabs(2) mod (2 mod (-1)), compiled withCompile<double, double>, threwDivideByZeroExceptionwhen the function was called. Evaluation and FastExpression giveNaNfor it.Where both operands are integers and the divisor is a constant that evaluates to 0, the node is now compiled to
NaN. A divisor inxis already compiled overdouble, where%by 0 isNaN, and the tests pin that it stays so."x + (2 mod 0)".Compile<double, double>("x")(1)DivideByZeroExceptionDivideByZeroExceptionNaN"x + (2 mod 0)".Compile<Complex, Complex>("x")(1)DivideByZeroExceptionNaNNaNThe
Complexrow was answered on master before this branch; the entry records it against 2.6.0, which no entry did.Found by
compilesweep, a check of compiled expressions against evaluation, at seed 10. No issue was filed.BREAKING-CHANGES.mdhas an entry, after the one for a compiled division by zero. Tests:ARemainderByZeroHasNoValue, whose three constant-divisor cases fail on master.ARemainderOfIntegersIsTheFlooredOne, which pins the integer path's sign convention and passes on master.Both are in
DivisionByZeroOverDoubleTest.🤖 Generated with Claude Code