Submission timeline
2007–2026One slot for every year since HN launched. Height is that year's peak points; orange marks a 100+ point or 50+ comment breakout. Select a bar to open its strongest thread.
First comments on top threads
HN comment orderThe big issue here is what you're going to use your numbers for. If you're going to do a lot of fast floating point operations for something like graphics or neural networks, these errors are fine. Speed is more important than exact accuracy. If you're handling money, or numbers representing some other real, important concern where accuracy matters, most likely any number you intend to show to the user as a number, floats are not what you need. Back when…
Just adding 0.1 to 0.2 in the language of your choice can be misleading because printing the number might just cut off the digits at some point. Here's an example using perl5: perl -e 'print 0.1+0.2' yields '0.3', which looks OK, however perl -e 'print 0.1+0.2-0.3' reveals '5.55111512312578e-17' So, it's better to print the result of 0.1+0.2-0.3 For what its worth, perl6 passes this test with flying colours.
Once I wrote a library for double-to-string conversion and vice versa, which handles such roundings nicely: https://github.com/mkupchik/dconvstr Key idea is not just to map binary floating point value X to a decimal floating point value Y, but instead (in extended precision, with 64-bit mantissa) compute an interval of decimal floating point values [Y1, Y2] which maps back to X (in standard precision, with 53-bit mantissa). Then choose such Y from [Y1, Y2] that Y has the shortest decimal representation.
A couple of thoughts I've always had about floating-point arithmetic: 1. IMO it's unfortunate that most languages default to floating-point. Most programmers, most of the time, would be better served by slightly slower but less confusing alternatives (it's nice that Raku uses rational numbers by default: similarly for integers, it's great that Python uses arbitrary-precision integers by default). At any rate, programmers would be a lot less confused about floating-point arithmetic if they had to opt in to it…
The first top-level comment from each of the four biggest threads, in HN’s own order. Excerpts are shortened; open a comment for full context.
- Breakout years
- 4
- Total points
- 1769
- Total comments
- 841
100+ points or 50+ comments
reference only — not used in Hall rules or ranking
reference only — not used in Hall rules or ranking
Every submission
| Date | Title as submitted | By | Points | Comments |
|---|---|---|---|---|
| 2015-11-13 | 0.30000000000000004First breakout | cocoflunchy | 533 | 240 |
| 2017-04-02 | 0.30000000000000004 | shawndumas | 380 | 130 |
| 2019-12-02 | 0.30000000000000004Best thread | beznet | 768 | 402 |
| 2021-03-26 | Your language isn’t broken, it’s doing floating point math | usrme | 2 | 0 |
| 2021-04-17 | Floating Point MathHall induction | gtirloni | 2 | 0 |
| 2021-08-19 | Floating Point Math | tosh | 2 | 0 |
| 2021-09-02 | 0.1 and 0.2 = 0.3 | kinduff | 2 | 2 |
| 2021-12-25 | 0.30000000000000004.com – Floating Point Math | stanislavb | 2 | 0 |
| 2022-04-01 | Floating Point Math | tosh | 2 | 0 |
| 2022-06-20 | Floating Point MathLatest 20+ point return | hegzploit | 56 | 65 |
| 2024-01-20 | Floating Point Math | throwup238 | 2 | 0 |
| 2024-08-12 | Floating Point Math | joelanman | 8 | 1 |
| 2024-12-29 | 0.1 and 0.2 = 0.30000000000000004 | Fake4d | 3 | 0 |
| 2025-02-05 | Floating Point Math | krykp | 1 | 0 |
| 2025-05-17 | Floating Point Math | mooreds | 4 | 1 |
| 2025-07-07 | Floating Point Math | dsego | 2 | 0 |
