4 ms·
Use a rational type :)
by person_of_color 7y ago
Use a rational type :)
- hansvm 7y agoI rather like this approach. It easily handles sub-cent transactions with any desired degree of precision (e.g. internal computations using the 9/10 cent bs at gas pumps). Internally everything is a rational quantity, and you just need to maintain correct (de) serialization at the system boundaries. That all gets thrown out the window when somebody really wants an exchange rate of pi for god knows why, but satisfying every real number is impossible, and satisfying every computable number exposes you to things like the halting problem, so having a system that just supports rationals seems like a good compromise.