by iopq · 11y ago · 0 comments
Can't store floating point numbers when you really need a ratio because it won't even work after you round it unless you reconcile different settings for precision. Decimal won't help here either.
So outside of niche scientific uses or something like graphics where you need performance, what do you really need floating point numbers for? I haven't had a need for floating point numbers outside of some mathematical formulae.
For representing real (i.e., potentially irrational or transcendental) numbers. Irrational and transcendental numbers are actually very common in nature.
But you're right that representing rational numbers with floating point is stupid.
Instead of inventing new one-size-fits-all coding schemes, people should focus instead on making the idea of a rational number type mainstream.
This wouldn't even be an issue worth discussing if popular programming languages and DBMS's supported rational numbers.
This is... a weird thing to say. Obviously floats are going to be most useful for math, and not useful for much else. They're number types.
1. Game score display where fractional points are possible
2. Currency
3. Any amount displayed to humans (like pounds of beef sold)
because decimal number correspond to what you're going to display to the user, while binary numbers are only useful for the result they produce inside an algorithm