3 ms·
whole numbers, ie cents 100 cents instead of 1.00 dollars
by binarysoul 16y ago
whole numbers, ie cents
100 cents instead of 1.00 dollars
- tzs 16y agoSo 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.