Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
robust float parsing in the standard library #2207
I did a proof of concept of porting musl's float parsing code to implement f128 parsing in stage1. You can see this implementation in
jumping in randomly here: for battle-tested float parsing, also check out the sqlite and luajit input parsers and compare their tradeoffs and performance characteristics (both are implemented to be more instruction cache friendly than stdlib versions too):
and as for roundtrip bit-for-bit value preservation (ignoring things like f16 having 2k "unique" NaNs (and same-meaning-different-bits just gets worse with larger binary lengths)), the best I end up with when running my systems in "super paranoid mode" is: parse string to native float/double/long double, convert native float back to string, string compare original string to see if match is exact.
But, now an entire new decision opens up: which reliable float pretty print algorithm will conversions be tested against?