News for hackers. Stuff that matters.

nonononyes

Re:Determinism with fixed point math on Friday July 10, 2015 @03:49PM (#9866316)
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.