Repository navigation
A compiled division by zero over double has no value - #2288
Merged
Rafael-SOWNet merged 2 commits intoOct 31, 2026
Merged
Conversation
Compiled over double, 1/x at 0 was +Infinity, where evaluation, FastExpression and the compiler over Complex all say NaN. The compiler emitted the IEEE quotient, and Math.Pow made 0^(-1) an infinity and 0^0 1, where evaluation makes both NaN too. A division over double or float now calls MathAllMethods.Divide, which answers a zero divisor with NaN, and Pow answers 0 to a power that is not positive with NaN. The elementwise division of a compiled matrix does as the scalar one does. DivisionByZeroOverDoubleTest takes seven expressions that have no value, over double and float, and four that have one; the seven fail on master. The suite, the trio, F#, AOT and the eight harnesses pass. work/compilesweep found 19 of these in 3000 random compositions. Fixes #2286. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A matrix written into the expression is divided entry by entry before it is compiled, and only a matrix argument reaches the compiled matrix division. AMatrixOverZeroHasNoEntries divides one by 0, and fails with master's TensorCompilation, whose entries were +Infinity. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2288 +/- ##
==========================================
+ Coverage 86.71% 86.72% +0.01%
==========================================
Files 310 310
Lines 67849 67861 +12
Branches 19690 19696 +6
==========================================
+ Hits 58836 58854 +18
+ Misses 4894 4886 -8
- Partials 4119 4121 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This was referenced Oct 30, 2026
Rafael-SOWNet
deleted the
a-compiled-division-by-zero-over-double-has-no-value
branch
October 31, 2026 04:22
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.
Compiled over
double,1/xat 0 was+Infinity, where evaluation, FastExpression and the compiler overComplexall say NaN. The compiler emitted the IEEE quotient.Math.Powlikewise made0^(-1)an infinity and0^0equal to 1, where evaluation makes both NaN.A division over
doubleorfloatnow callsMathAllMethods.Divide, which answers a zero divisor with NaN, andPowanswers 0 raised to a power that is not positive with NaN. A compiled matrix argument divided by a scalar now does the same, entry by entry."1/x".Compile<double, double>("x")(0)+InfinityNaN"x^(-1)".Compile<double, double>("x")(0)+InfinityNaN"x^x".Compile<double, double>("x")(0)1NaN"A / x", a matrixAatx = 0+InfinityentriesNaNentriesDivisionByZeroOverDoubleTest: the seven scalar cases fail on master, and the matrix case fails with master'sTensorCompilation. The suite (18,286), the trio, F#, AOT and the eight harnesses pass locally.work/compilesweepfound 19 of these in 3000 random compositions.This leaves the other half of #2286 open: the 60 expressions with a real value and a non-real intermediate, which the
doublecompiler gives as NaN. That is a question for the maintainer. Also found while testing, and filed as #2287: compiledx / A, with a matrix argument, divides entry by entry where evaluation multiplies by the inverse.Part of #2286.
🤖 Generated with Claude Code