3 ms·
> I think it's probably related to the fact that printf() doesn't have any format specifiers for float that do What You Really Want, which is: print the shortes
by eru 11y ago
> I think it's probably related to the fact that printf() doesn't have any format specifiers for float that do What You Really Want, which is: print the shortest number that will parse back to the right value.
Lots of language support the proper behaviour these days. Haskell/ghc does, for example.
[https://docs.python.org/3/tutorial/floatingpoint.html https://docs.python.org/3/tutorial/floatingpoint.html]:
> Historically, the Python prompt and built-in repr() function would choose the one with 17 significant digits, 0.10000000000000001. Starting with Python 3.1, Python (on most systems) is now able to choose the shortest of these and simply display 0.1.