2 ms·
It isn't enough. Suppose you have something in dollars and cents (in a float), and you want a count of pennies. 2.22 * 100.0 == 222.00000000000003, not 218.0.
by roywiggins 8y ago
It isn't enough. Suppose you have something in dollars and cents (in a float), and you want a count of pennies.
2.22 * 100.0 == 222.00000000000003, not 218.0. This is a) wrong and b) not an integer.
Either you are aware of this and manually round the result to an integer, or you use fixed-point math.