This is the kind of operation where you really need to work it out with pen & paper to see what's going on. Use the windows calculator if it makes things easier.
Remember that modulus retrieves the remainder of a number, as if it had been divided by that number. eg, 10 mod 3 = 1
there's no such thing as remainder when dealing with floating point values (values which contain fractions of whole numbers)
One way to make sure that all your currency figures are whole numbers is to multiply them all by 100. so 25 dollars becomes 2500, and 0.01 dollars becomes 1. (you've changed the units from dollars to pennies. this ought to make your calculations alot simpler).
Here's a worked example in pseudocode. start with a value of
$35.43CODE
$35.43 dollars mult 100 == 3,543 pence
3543 pence div 100 == 35 dollars
3543 pence mod 100 == 43 pence
43 pence div 25 == 1 quarter
43 pence mod 25 == 18 pence
18 pence div 10 == 1 dime
18 pence mod 10 == 8 pence
8 pence div 5 == 1 nickel
8 pence mod 5 == 3 pence
Total: $35.43
=========
35 Dollars + 1 quarter + 1 dime + 1 nickel + 3 pence.
This post has been edited by Bench: 1 Dec, 2007 - 05:25 PM