3 ms·
I think Python was the first to bring this into my consciousness. See this enhancement request, which changed the float-to-string conversion from seventeen sig
by SloopJon 6y ago
I think Python was the first to bring this into my consciousness. See this enhancement request, which changed the float-to-string conversion from seventeen significant figures to shortest:
https://bugs.python.org/issue1580 https://bugs.python.org/issue1580
After they did that, I learned that Scheme specifies similar behavior. In fact, I think it was added to R4RS after the Steele and White paper. As the article says, this behavior spread across languages, so that it's weird to see something different now.
If you want to nerd out on this, here are a few other posts that explore the topic:
https://www.exploringbinary.com/the-shortest-decimal-string-that-round-trips-examples/ https://www.exploringbinary.com/the-shortest-decimal-string-...
https://www.exploringbinary.com/the-shortest-decimal-string-that-round-trips-may-not-be-the-nearest/ https://www.exploringbinary.com/the-shortest-decimal-string-...
https://www.exploringbinary.com/java-doesnt-print-the-shortest-strings-that-round-trip/ https://www.exploringbinary.com/java-doesnt-print-the-shorte...