Re:There Are Only Four Billion Floats–So Test Them All (2014)
by ignoramous on Thursday February 09, 2023 @04:52PM
(#34732072)
> ...but we use a slightly worse (but more performant) routine.
If it (dragonbox?) is more performant, why is it also worse?
Re:There Are Only Four Billion Floats–So Test Them All (2014)
by wiredfool on Thursday February 09, 2023 @05:25PM
(#34732548)
Presumably it's not as accurate?
Re:There Are Only Four Billion Floats–So Test Them All (2014)
by nickpeterson on Thursday February 09, 2023 @06:24PM
(#34733211)
Someone needs to make a bumper sticker for developers that says “fast and wrong”. I’d imagine non-programmers would buy more of them for other reasons…
Re:There Are Only Four Billion Floats–So Test Them All (2014)
by Dylan16807 on Thursday February 09, 2023 @07:55PM
(#34734126)
It's only on edge cases that floating point isn't mathematically wrong. And sometimes you don't mind an extra couple ULPs of drift.
Re:There Are Only Four Billion Floats–So Test Them All (2014)
by fsckboy on Friday February 10, 2023 @12:16AM
(#34735903)
fast and wrong? that's not a great bumper sticker to have when you're getting pulled over for speeding.
Re:There Are Only Four Billion Floats–So Test Them All (2014)
by dantillberg on Friday February 10, 2023 @12:05AM
(#34735835)
The fast algorithm is less accurate in the least significant bits. In zX41ZdbW's first link above, there's a code comment that includes the exact count of numbers grouped by how inaccurate the results were.
https://github.com/ClickHouse/ClickHouse/blob/master/src/IO/...
- we create a table, insert all four billion floats there, and check our functions with SQL queries.
Currently, the state-of-the-art library is https://github.com/lemire/fast_double_parser, but we use a slightly worse (but more performant) routine.
It is also interesting how to format floats in string in an efficient and user-friendly way.
For this problem, we switched iteratively: strtod -> Google's Double Conversion -> Ryu (patched) -> Dragonbox. Currently, we use Dragonbox.