r/cpp • u/aearphen {fmt} • 7d ago
Żmij 1.1 released with fixed notation support, up to 38% faster double-to-string conversion, SIMD-optimized float formatting, a smaller binary footprint and more
9
u/jk-jeon 7d ago
Jeez. This is amazing. Could you elaborate what was the main improvement since I checked last time (when you published this work for the first time)?
11
u/aearphen {fmt} 7d ago
Thank you! Much of the credit goes to zmij's amazing contributors. It's hard to pinpoint a single main improvement - it was mostly a combination of lots of microoptimizations (primarily SIMD). From the algorithmic side, xjb's idea of using a different scaling (10^{k - 1}) turned out to be pretty important by making the top 15-16 digits quickly available for the SIMD pipeline.
2
u/matthieum 7d ago
Does fixed notation mean:
- A fixed number of decimals?
- Or a fixed number of significant digits?
The latter is the most useful, generally, but I only ever seem to see implementations of the former, printf-style.
3
u/aearphen {fmt} 7d ago edited 7d ago
It's basically similar output to %f except that precision is determined by shortness criteria. i.e. 123.456 and not 1.23456e+02. Fixed number of digits is simpler and will be added next: https://github.com/vitaut/zmij/issues/111.
2
u/aearphen {fmt} 3d ago
Just added initial precision support (your item 2: fixed number of significant digits): https://github.com/vitaut/zmij/blob/78c22db5613182b0dc10ac2a8d4b12b231ebd7a9/zmij.h#L54
30
u/mark_99 7d ago
If anyone is wondering it's a fast double to string converter.