2 ms·
So basically integers. Floating point can represent integers, and floating point add, subtract, and multiply on integers is exact, so why not use floating point
by tzs 16y ago
So basically integers. Floating point can represent integers, and floating point add, subtract, and multiply on integers is exact, so why not use floating point to represent cents?
On a 32-bit machine, using native integers limits you to $40 million dollars or less ($20 million or less if you have to use signed integers). Double precision floating point gives you something like 52-bit integers.
When dividing, you would have to explicitly use floor, round, or ceil to make the result be an integer.