Skip to content

The signum of a value that does not exist has none - #2243

Merged
Rafael-SOWNet merged 2 commits into
masterfrom
sgn-of-nan-has-no-value
Oct 30, 2026
Merged

Rafael-SOWNet merged 2 commits into
masterfrom
sgn-of-nan-has-no-value

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Fixes #2241.

Signumf's rule took a real number's sign from its EDecimal, and EDecimal's Sign of NaN is 1. So the signum of anything without a value was 1: sgn(NaN), sgn(0/0) and sgn(-1 provided false), and 1 + sgn(-1 provided pi < 3) was 2. That is a value where there is none, on 2.6.0 as on master. Number.Signum already gave NaN for NaN; only this rule did not.

A NaN real is now its own signum, as abs and sin already passed a NaN through.

2.6.0 and master now
"sgn(NaN)".ToEntity().Evaled 1 NaN
"sgn(-1 provided false)".ToEntity().Evaled 1 NaN

Found by comparing the compiled sgn with evaluation for #2242: the compiled value was NaN there, and evaluation's was 1.

Tests: SignumOfNaNTest has five spellings of a missing value, checked by Evaled and by Simplify, all of which fail on master; five signs that stay as they were; and the compiled value. Full suite 18124/0, interactive trio, AOT smoke 73/0, all frameworks build.

🤖 Generated with Claude Code

Signumf's rule took a real number's sign from its EDecimal, and
EDecimal's Sign of NaN is 1. So the signum of anything without a value
was 1: sgn(NaN), sgn(0/0), sgn(-1 provided false), and
1 + sgn(-1 provided pi < 3) was 2. That is a value where there is none,
on 2.6.0 as on master. Number.Signum already gave NaN for NaN; only this
rule did not.

A NaN real is now its own signum. abs, sin and the rest already passed a
NaN through.

Found by comparing the compiled sgn with evaluation for #2242. The
compiled value was NaN there, and evaluation's was 1.

SignumOfNaNTest: five spellings of a missing value, by Evaled and by
Simplify, all failing on master; five signs that stay as they were; and
the compiled value.

Fixes #2241.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@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.70%. Comparing base (b8a6a6f) to head (501e240).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2243      +/-   ##
==========================================
+ Coverage   86.68%   86.70%   +0.01%     
==========================================
  Files         310      310              
  Lines       67766    67785      +19     
  Branches    19660    19664       +4     
==========================================
+ Hits        58744    58770      +26     
+ Misses       4909     4902       -7     
  Partials     4113     4113              
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.25% <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 Δ
...nuous/Evaluation.Continuous.Arithmetics.Classes.cs 86.98% <100.00%> (+0.04%) ⬆️

... and 11 files with indirect coverage changes

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

Every one was an InnerSimplified order disagreement on a sum with
sgn(a / 0) in it. a / 0 has no value, and its signum was 1, so the two
orders of the sum came out as different expressions. sgn(a / 0) is now
NaN, which makes the sum NaN in either order. 0 findings appeared, and
the baseline goes from 2091 to 2039.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Rafael-SOWNet
Rafael-SOWNet merged commit bd750c4 into master Oct 30, 2026
35 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in AngouriMath Oct 30, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the sgn-of-nan-has-no-value branch October 30, 2026 13:47
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.

sgn(NaN) evaluates to 1: sgn(-1 provided false) is 1

1 participant