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
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
SignificantNumber stores its value as a normalized PreciseNumber, which moves trailing zeros into the exponent (README "Trailing zero removal", README.md:283-290). SignificantDigits is then read straight from that value (SignificantNumber/SignificantNumber.cs:98). Multiplication, division, Pow/Exp and comparison all take the result's precision from LowestSignificantDigits (line ~185, used at ~240, ~253, ~385, ~625, ~677).
Trailing zeros are significant in a measurement, so the type loses precision the user actually has. 1.20 is treated as 2 significant figures, and 10.0, 2.0 and 4.00 as 1. The type has no way to represent a value such as 2.50 or 10.0 with its real precision.
The collapse spreads: once one operand ends in 0, every later * and / in the chain drops the digits the user supplied. The migration guide's own example, ToMeters(10.ToSignificantNumber()), returns 3 rather than the 3.048 its comment implies, for the same reason.
For a library whose purpose is significant-figure arithmetic, this is the most common way real measured inputs are written.
Suggested fix
Track precision separately from the normalized value:
Add a field for significant digits, or for the least-significant decimal place, next to Value. Parse and string input set it from the literal ("1.20" → 3 s.f.); numeric conversions set it from the source's natural digits, or from an explicit overload.
Have ToString pad with the significant trailing zeros (10.0, 2.50).
This changes the struct's equality and layout, so it is likely v3 material. A smaller first step is an opt-in Parse/constructor overload that keeps precision from the literal.
Acceptance criteria
SignificantNumber.Parse("1.20").SignificantDigits == 3, and Parse("10.0") reports 3.
Category: Bug. The issue has no label yet; bug fits.
Priority: High. The library exists to do significant-figure arithmetic, and the most common way to write a measured value (1.20, 10.0) loses precision. The loss then compounds through every *, / and Pow in a chain. The complete fix changes the struct's layout and equality, so it is likely a major version. The opt-in Parse overload the issue suggests would be a smaller first step.
Area / suggested assignment: core type: SignificantNumber precision tracking (SignificantDigits, LowestSignificantDigits), Parse, and ToString.
Activity
matt-edmondson commentedon Sep 29, 2026
Triage
bugfits.1.20,10.0) loses precision. The loss then compounds through every*,/andPowin a chain. The complete fix changes the struct's layout and equality, so it is likely a major version. The opt-inParseoverload the issue suggests would be a smaller first step.SignificantNumberprecision tracking (SignificantDigits,LowestSignificantDigits),Parse, andToString.+and-), which would read the same new precision field.Generated by Claude Code