|
|
|
|
|
by tovej
986 days ago
|
|
How can you say that so confidently?
Floating point is terrible for decimals, as any number not consisting of only 0's and 5's after the decimal point does not have a precise representation.
What if you're counting ratios or differences? Those values are no longer precise. What if you're comparing those ratios or differences? That comparison cannot be trusted. What if you have a NaN? Now all your comparisons return false and any values you calculate from the NaN will also be NaN. There is no way you can confidently claim these issues won't show up in a production system without doing fuzzing and formal verification. Just use big integers, 64 bit integers can represent 18 quintillion (short scale) values, which if you're trading in fractions of cents should be enough of a range for the foreseeable future. 128 bit integers will always be enough. |
|