News for hackers. Stuff that matters.
Re:Fintech engineering mistakes by fvdessen on Wednesday June 28, 2023 @11:04AM (#36507505)
There are multiple factors:

Doubles can exactly represent all 16 digit ints (IIRC) which is good enough for most use cases, you can catch the out of range cases (as you should do with ints as well)

If you use long ints you must track the decimal precision along the value which is not always trivial if you use mixed currencies.

Long ints are not guaranteed to correctly roundtrip through json serialisation / deserialisation

Doubles are easier to handle in the frontend

Currency math is different enough from regular math that you need special operator functions anyway so it’s not like ints are easier to handle either

There are no comments on this comment yet.