3 ms·
Floats are fine for speculation. But they should not be used to record actual transactions. I typically use the smaller unit of a currency to store transaction
by dotancohen 2y ago
Floats are fine for speculation. But they should not be used to record actual transactions.
I typically use the smaller unit of a currency to store transaction amounts. E.g., for a US transaction of $10, I would store the integer 1000 because that is 1000 cents.
- zie 2y agoOr just use decimal numbers instead. Decimal libraries abound. Then you can do rounding however your jurisdiction/bank/etc does it too.