Skip to content

An exact rational is zero, positive or negative as it is - #2280

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
an-exact-rational-is-zero-only-when-it-is
Oct 31, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
an-exact-rational-is-zero-only-when-it-is

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

0 / 10^(-200) was NaN, where it is 0, and so was 0 ^ (1/10^250). Complex.IsZero, Real.IsPositive and Real.IsNegative read the decimal. A rational's decimal is written out in the precision context, whose exponent range writes every rational smaller than about 1e-199 as 0. So the divisor was taken to be zero, and the exponent to be not positive. This is what made #2270's reduced row echelon form NaN: it divided 0 by a denominator near 1e-246.

A rational part is now read by the ERational it holds. Its decimal is written out only when asked for, so these checks no longer write one out.

Input 2.6.0 Now
0 / 10^(-200) NaN 0
0 / (3/10^260) NaN 0
0 ^ (1/10^250) NaN 0

ATinyRationalIsNotZeroTest: 6 of its 9 cases fail on master, and the 3 for things that have not changed pass on both. The suite (18,265), the trio, F#, AOT and the eight harnesses pass locally.

Left out on purpose: 0 % (1/10^250) is still NaN, through Real's decimal %. 1/10^250 = 0 is True, which is Equalsf's tolerance (#1019).

Fixes #2277.

🤖 Generated with Claude Code

0 / 10^(-200) was NaN, where it is 0, and so was 0 ^ (1/10^250).
Complex.IsZero and Real.IsPositive and IsNegative read the decimal,
and a rational's decimal is written out in the precision context,
whose exponent range writes every rational under about 1e-199 in size
as 0. So the divisor was taken for zero, and the exponent for not
positive. That is what made #2270's reduced row echelon form NaN,
dividing 0 by a denominator near 1e-246.

A rational part is now read by its ERational, which it holds; its
decimal is written out only when asked for.

ATinyRationalIsNotZeroTest takes five quotients and powers of tiny
rationals, three that have not changed, and the sign and the zero
test of 1/10^250 and its negation; six fail on master. The suite, the
trio, F#, AOT and the eight harnesses pass.

Diagnosed by the subagent that traced #2270.

Fixes #2277.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Rafael-SOWNet Rafael-SOWNet added this to the 2.7.0 milestone Oct 30, 2026
@Rafael-SOWNet Rafael-SOWNet moved this from Todo to In review in AngouriMath Oct 30, 2026
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.71%. Comparing base (47ea3b3) to head (8059e73).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2280   +/-   ##
=======================================
  Coverage   86.71%   86.71%           
=======================================
  Files         310      310           
  Lines       67845    67847    +2     
  Branches    19689    19691    +2     
=======================================
+ Hits        58830    58835    +5     
+ Misses       4895     4891    -4     
- Partials     4120     4121    +1     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.26% <100.00%> (+<0.01%) ⬆️
fsharp 32.97% <ø> (ø)
interactive 40.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...Continuous/Entity.Continuous.Complex.Definition.cs 82.17% <100.00%> (+0.17%) ⬆️
...ty/Continuous/Entity.Continuous.Real.Definition.cs 88.88% <100.00%> (ø)

... and 9 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Rafael-SOWNet
Rafael-SOWNet merged commit 4d049d5 into master Oct 31, 2026
35 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in AngouriMath Oct 31, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the an-exact-rational-is-zero-only-when-it-is branch October 31, 2026 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

0 divided by a rational smaller than 1e-199 is NaN

1 participant