Originally Posted by
Eranga
fishtoprecords, I'm totally confusing with your comments. You advice not to use double because of decimal points? Is it?
Yes, you are confused.
My advice is to never use double or float for currency.
Floating point numbers are great for engineering. Engineers design for limited accuracy in numbers. Floating point numbers are rarely exact (they are only exact for powers of two, such as 1/2, 1/4, etc.)
Accountants insist on exact numbers. Any system that uses money must exactly add up. You simply can not do this with float or double.
The solution is to use fixed point. The easiest is to use the integer number of pennies, and accept the decimal point on input, and put it there on output.