Better HN
topnewbestaskshowjobs
Log inSign up

nonononyes

2 karma · joined Jul 10, 2015 (11y ago) · 1 submissions

Submissions

comment 11y ago · link · parent

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/

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.