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
double.ToString("R") is not round-trippable for 2^-25 and 2^-958 on .NET 10 (regression from .NET 8) #135582
On .NET 10, double.ToString("R") (and the default shortest round-trip ToString()) returns a string that does not parse back to the original value for some powers of two. The same values format correctly on .NET 8.
Found while validating an RFC 8785 (JSON canonicalization) number serializer against 100,000 JSON.stringify reference pairs.
The 16-digit output is one digit too short and parses to a neighbouring value. Both inputs are exact powers of two (zero mantissa bits), where the rounding interval is asymmetric (the lower neighbour is half as far away), so this looks like the lower boundary being treated as symmetric in the shortest-digits path.
Regression?
Yes. .NET 8.0.28 prints the expected values. .NET 9 was not tested.
Scanning all 2,098 positive powers of two (Math.ScaleB(1.0, e), e = -1074 … 1023), exactly these two fail on .NET 10.0.12; on .NET 8.0.28 none fail. 1,000,000 random finite doubles round-trip correctly on both.
Known Workarounds
Check the round trip and fall back to ToString("E16") (17 significant digits) or search precisions 1–17 for the shortest one that parses back.
Configuration
.NET 10.0.12 (SDK 10.0.401), Windows 10 22H2 (10.0.19045), x64
Comparison: .NET 8.0.28, same machine
Other information
Possibly related to the floating-point formatting work in #131068 / #134621 (not verified).
Activity
dotnet-policy-service commentedon Oct 11, 2026
Tagging subscribers to this area: @dotnet/area-system-numerics
See info in area-owners.md if you want to be subscribed.
[release/10.0] Fix Dragon4 shortest formatting for exact powers of two (