cash program guidance

Last edited on
please put your code in code tags '<>' so it's not a nightmare to read. ill edit this post if i find anything .
Last edited on
C++ handles floating point numbers a little strange, but hides it from all of the users. take a look at this:

cout.precision(50); //notice the variables printed
    double var = 3.37;
    double var2 = 3.38;
    cout << var << endl << var2 << endl << var2- var;


when multiplying by one 100, the last var wont exactly equal one(thus why one penny always seems to be missing). A fix would be to use ceil() with the entire equation:

int remain = ceil(((tenderP - purchaseP) - (floor(tenderP - purchaseP))) * 100);

Sorry about the late reply, this one was hurting my brain a bit before i finally noticed the conversions from double to int.
Last edited on
for future reference, when your topic is finished simply mark is as solved. This way other users can read these topics and learn something, or if this topic pops up in google readers can understand what the question was. No need to restore this post, but keep your future posts in tact.
Topic archived. No new replies allowed.