Hacker News new | ask | show | jobs
by jessaustin 4279 days ago
That's fine until you start using floating point values in order to satisfy this SI fetish. (I guess you like farads and henries too.) It's much better to use fixed point and keep track of your multiplier. A sufficiently advanced type system could do this, but at some point it will require careful thinking about precision.
1 comments

Using fixed point and tracking your multiplier is exactly like using floating point.
Floating point is treated differently by compilers, involves different components of the processor, generates different types of errors, and has different performance. Perhaps there is some perspective from which that proposition is true?
A perspective where one is more familiar with IEEE754 than your in-house custom fixed-point implementation of choice?

There are plenty of applications where it makes sense to do something different because you need to accommodate special hardware (e.g. FPGAs), because you want a different representation density/range, or because external policy effectively dictates the most natural format (e.g. finance). But in the absence of a pressing concrete reason to ditch 754 floats, they are BY FAR the best option for high performance, reproducible, portable, debuggable math with abundant documentation and pre-existing pools of expertise. They're far from trivial but so is the fixed-point code you would replace them with.

If someone couldn't be bothered to learn the relevant intricacies of IEEE754, why do you expect them to do a better job re-implementing the stuff on top of integer math (or picking apart the in-house attempt to do so)? Shifting from problems of the "intern forgot to reset the rounding mode" variety to the "Newton's method code erroneously terminates one cycle too early if the last bit is a 1" variety hardly seems productive.

I won't cover the ground the other response covered (implementing your own fixed point because IEEE754 isn't good enough for you is ... nutty) but the issue here is using daft units vs. using SI units, and the thinner and thinner straws people clutch at to claim that using SI units isn't simply better. Good grief.