Repository navigation
Description
Proposal
I propose adapting the shortest-decimal producer in ZmijSharp at b2b9ef3 for CoreLib’s unconstrained-precision float and double formatting. It supplies digits and scale to the existing number buffer and presentation path, with no public API change.
The producer uses Victor Zverovich's original Żmij as its algorithmic reference. It offers two cached-power profiles: compact stores less data, while full avoids cache reconstruction.
Local performance
The benchmark measures canonical double significand and exponent production. Unrounded scaling is a local double specialization of the shortest path from #131068; its adaptation notes are in the repository. Setup checks that all three producers return the same result for every input.
Windows 11 x64, .NET SDK 11.0.100-rc.1.26425.128, BenchmarkDotNet DefaultJob; 10,000 deterministic finite, nonzero values per corpus. Results are mean ns/value (lower is better). All cases reported zero managed allocations.
| Corpus | Żmij compact | Żmij full | Unrounded scaling |
|---|---|---|---|
| Varied long significands | 8.049 | 5.613 | 6.817 |
| Random raw IEEE bits | 10.055 | 6.164 | 8.613 |
| Simple values | 18.354 | 15.215 | 15.160 |
The full profile is faster on the first two corpora and similar on simple values. The compact profile uses less data but takes longer on all three. These measurements cover decomposition, before digit writing and text presentation. Full results, variation, and reproduction command.
Data and code size
The minimal Release net11.0 DLLs use the same project and public adapter.
| Measure | Żmij compact | Żmij full | Unrounded scaling |
|---|---|---|---|
| Raw cached-power constants | 830 B | 9,888 B | 11,136 B |
Shortest.Core.dll file length |
12,288 B | 20,480 B | 19,968 B |
| Listed x64 JIT instruction bytes | 1,562 B | 1,383 B | 1,391 B |
DLL lengths include PE layout, metadata, and IL. The JIT row covers the listed call tree from one x64 run. These figures are not incremental CoreLib size estimates. The size record identifies the counted constants and methods.
Correctness
The standalone formatter matched the installed .NET 11 RC runtime’s default invariant char output for all 2³² binary32 encodings. A deterministic 100-million-pattern binary64 sample matched default char and UTF-8 output. Sampled and exponent-boundary cases also passed an independent exact-integer shortest-decimal oracle. Coverage and commands.
A matched CoreLib build would establish complete formatting performance and incremental size impact.
Activity
dotnet-policy-service commentedon Sep 25, 2026
Tagging subscribers to this area: @dotnet/area-system-numerics
See info in area-owners.md if you want to be subscribed.
[-]Evaluate a compact Żmij-style shortest float/double producer alongside #131068[/-][+]Evaluate a Żmij-style shortest float/double producer for CoreLib[/+]Mrnikbobjeff commentedon Sep 25, 2026
FYI I have integrated this change in the RYU branch and will have a full bench comparison in an hour since I found one double test bug and managed to optimize the reference US algorithm and the RYU reference algorithm to always beat US. Both are written in the runtime style as well, eliding the unsafe code you have in your reference implementation
Mrnikbobjeff commentedon Sep 25, 2026
Benchmarks (mean ns;
usc= PR #131068,ryu= spacing‑28 Ryu,zmij= compact,zfull= full table)I can port the small number optimization I had in ryu to this, then the benchmark results should favor you even more. I would adapt this and then change the existing pr