Live data from Hacker News

Floating point numbers, and why they suck

riskledger.com

1–10 of 46 posts

Re: Floating point numbers, and why they suck

#3
This is an issue that has bitten people before. Indeed, there's probably been some discussion of it and might even be some common mitigations taught as "best practice" in some places.

Do we ever need to store floats? using them in flight is one thing, but stored data so often needs to be some fixed precision.

Re: Floating point numbers, and why they suck

#4
I wish that fixed point numbers (as in Qx.y) was a first class citizen in programming languages. As well as saturation arithmetic.

Actually I wonder if anybody did a performance/power comparison of using floating point vs fixed point math in some common tasks using modern CPUs with extensive FP support.

Re: Floating point numbers, and why they suck

#6
The problem is that we're still stuck with only binary floating point types in our CPUs and compilers and runtime environments, over a decade after ieee754 released their decimal float spec [1].

Once we finally move away from binary floats, these nasty binary-exponent-decimal-exponent lossy conversions will end (as will the horribly complicated nasty scanf and printf algorithms).

This is a solved problem. Our actual problem now is momentum of adoption.

I've anticipated that this will eventually happen (hopefully sooner rather than later), and proactively marked binary floats as "legacy formats" [2].

[1] https://en.wikipedia.org/wiki/Decimal64_floating-point_forma...

[2] https://github.com/kstenerud/concise-encoding/blob/master/ce...

Re: Floating point numbers, and why they suck

#7

I wish that fixed point numbers (as in Qx.y) was a first class citizen in programming languages. As well as saturation arithmetic. Actually I wonder if anybody did a performance/power comparison of using floating point vs fixed point math in some common tasks using modern CPUs with extensive FP support.

They are a first class citizen in Ada, you even get two (three) varieties: http://www.ada-auth.org/standards/12rm/html/RM-3-5-9.html / http://www.ada-auth.org/standards/12rm/html/RM-3-5-7.html

Re: Floating point numbers, and why they suck

#10
I'm very annoyed by this title. It's a beginners mistake and FP numbers just are what they are -- a tradeoff between precision, range and efficiency. If you use FP, you should be familiar with its intricacies in the same way a C programmer needs to be aware of unsigned overflows.
Post reply on HN