You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Regression since #119: integer sums stall at round numbers. 10 + 2 == 10, 100 + 25 == 100, 20 - 3 == 20, and a sum += 2 loop stops at 10 #124
PreciseNumber normalizes integers by moving trailing zeros into the exponent: 10 becomes 1E1 and 100 becomes 1E2. Since fc66077 (#119, the fix for #107), CountDecimalDigits (SignificantNumber/SignificantNumber.cs:155) returns -value.Exponent without clamping it. As a result, any whole number ending in 0 is treated as known only to the tens or hundreds place, including one that came from int.ToSignificantNumber(). Add and Subtract then round the result to that place through LowestDecimalDigits (line 163 onward).
Failure scenarios
Measured at HEAD a15223e, then against fc66077^ in a worktree:
The last row shows what happens to an ordinary accumulator: once it reaches 10, every later + 2 rounds back to 10, so a running total of integer counts silently stops growing.
The full fix is the separate precision tracking proposed in #120. Until that lands, one of these:
Treat values from integer conversions (int/long/... ToSignificantNumber(), CreateChecked from integer types) as exact to the units place, i.e. clamp CountDecimalDigits to ≥ 0 for them. Only an explicit coarse input, such as Parse("1.2E3"), would then round to tens or hundreds.
Priority: High. Ordinary integer arithmetic silently returns wrong results (10 + 2 == 10), and accumulators stop growing. This is the library's core operation and fails with no error.
Area / suggested owner:CountDecimalDigits / LowestDecimalDigits in SignificantNumber.cs (@matt-edmondson).
Activity
matt-edmondson commentedon Oct 5, 2026
Triage
10 + 2 == 10), and accumulators stop growing. This is the library's core operation and fails with no error.CountDecimalDigits/LowestDecimalDigitsinSignificantNumber.cs(@matt-edmondson).Parsewith*//, while this covers addition on integer conversions and the Round sums and differences to tens and hundreds when an operand is that coarse #119 regression. The interim clamp proposed here can ship before the full precision-tracking fix in Measured trailing zeros count as insignificant: Parse("1.20") has 2 sig figs, so 1.20 × 1.23456 = 1.5 and 9.81 × 10.0 = 100 #120. ++ and -- skip the addition rounding rule: 1.2E3++ gives 1201, while 1.2E3 + 1 gives 1200 #125 should land with or after this.Generated by Claude Code