Convert dollars in double to cents in int:
int val = (int)(doubleVal*100);
Type: Posts; User: Norm
Convert dollars in double to cents in int:
int val = (int)(doubleVal*100);
Convert each of the variables contents to cents in an int variable BEFORE subtracting.
That does the multiply and cast AFTER the subtraction. Do it BEFORE any math operations.
Print out the value of change from that expression to see.
Convert the contents of these to cents BEFORE doing any math: tendered and spent
Did you see this:
Convert the amounts to cents before doing any math with them.
Can you copy the contents of the console window and paste it here that shows the problem?
Convert the amounts to cents before doing any math with them.
On Windows: To copy the contents of the...