logoalt Hacker News

adrian_b • yesterday at 5:05 PM • 1 reply • view on HN

Using 64-bit integers as a count of a hundredth or of a thousandth part of a cent should be enough for most purposes (i.e. up to ten thousand or one hundred thousand billions of $).

If you want to be able to count trillions of trillions of dollars with a resolution of a millionth part of a cent, then you can use 128-bit integers.

Computing exactly with 128-bit integers is many times faster than computing only approximately with decimal floating-point numbers and it requires less memory storage for the same dynamic range.


Replies

fourier54 • yesterday at 5:11 PM

Actually 128 int uses 2 times the storage for less dynamic range. I agree however that for financial applications int is always better. You don't want float dynamic range on finance calculations