r/cpp • u/aearphen {fmt} • Sep 22 '26
Żmij 1.2 "the proof is in the printf" released with full to_chars implementation, formal verification, improved performance and more
Żmij 1.2 is out. It started as a shortest round-trip double-to-string converter; this release makes it a full formatter.
- Scientific, fixed, general and hex notation with a caller-specified precision, matching
printf's%e,%f,%gand%a. long double, covering both x87 80-bit extended and IEEE binary128.- Full FP
std::to_charsimplementation that works in C++14 and is several times faster and smaller than typical standard library implementations. - The main algorithms are now proved correct in Lean 4.
floatconversion is about 23% faster than 1.1,doubleis 1-4% faster.- Initial
constexprsupport.
Release notes: https://github.com/vitaut/zmij/releases/tag/v1.2
80
Upvotes
9
u/UndefinedDefined Sep 23 '26
Any chance this actually gets into standard library implementations?
Why to use charconv if there is many times faster Zmij even for C++14.
14
u/azswcowboy Sep 22 '26
Love to see the continued enhancement in the field for this seemingly simple, but difficult problem. One thing you might consider is changing the license to either Apache with llvm exception or boost since at least a couple of the library vendors can’t accept mit licensed code due to the attribution clause.
2
u/Charming-Work-2384 Sep 22 '26
Release build binary size?
2
u/jk-jeon Sep 23 '26
A lot of new stuff!
Could you elaborate roughly what did you do for the given precision thing?
5
u/Vast_Dimension_4542 Sep 23 '26
This is amazing. Time to replace the floating point to chars code I wrote back in 2009 :)
Well, actually, it's been an overdue task item for quite a while. The longer I put it off, the better and faster the replacements become.
2
u/realestLink Sep 23 '26
This is sick. I'll definitely check this out for sure
-20
u/torsten_dev Sep 22 '26
AI Slop or not?
0
u/[deleted] Sep 22 '26
[deleted] — view deleted comment