News for hackers. Stuff that matters.
Re:Rendering floating numbers: advances in problems you didn... by jrumbut on Friday October 30, 2020 @01:17AM (#24939393)
This is in the running for the best HN post I've seen this year. I've read all about floating point precision, never about rendering.

The existence of this problem is so obvious in hindsight and I was so completely unaware of it previously.

Re:Rendering floating numbers: advances in problems you didn... by SloopJon on Friday October 30, 2020 @02:15AM (#24939655)
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

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-...

https://www.exploringbinary.com/the-shortest-decimal-string-...

https://www.exploringbinary.com/java-doesnt-print-the-shorte...