3 ms·
Yes, one should never, ever use floats to handle currency values. Since currencies round to decimal digits, one should use decimal numbers. Databases that store
by nonononyes 11y ago
Yes, one should never, ever use floats to handle currency values. Since currencies round to decimal digits, one should use decimal numbers. Databases that store currency values have a "decimal" type too. Using integers works, but have caveats:
http://floating-point-gui.de/formats/integer/ http://floating-point-gui.de/formats/integer/
Some programming languages, like Haskell, default to Bignums (or Rationals for numbers that aren't integers) unless you ask for something else. I think that's a good default.