by hatthew · 2y ago · 0 comments
Obviously, not all int64 values are representable in float64 (double).
But the resulting type is still going to have its own limitations and sharp edges. Floats are not the right tool for every job but they are quite good at the jobs they are right for. Learning how they work is more useful than lamenting their existence.
But floats are not the right representation for values that need to exactly match, like an ID, to be sure.
If I’m off by half a cent it’s annoying. If I’m off by half a row I get nothing.
The thing is that almost all of the problems we had in my initial story came from choosing system defaults. All except the PK algorithm.
However I read the post I responded to as decrying all floating-point formats, regardless of base. That leaves only fixed-point (fancy integers) and rationals. To represent numbers with the same range as double precision, you'd need about 2048 bits for either alternative. And rational arithmetic is really slow due to heavy reliance on the GCD operation.