Results 1 to 2 of 2

Thread: Problem with a line

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2011
    Posts
    40

    Problem with a line

    Code:
    change_in_cents = (int)(floor(tendered - purchases)* 100.0 + 0.5);
    im getting wrong results, if tendered was declared 29.26 and purchase was 100. i should be getting 7074 but im getting 7000. anyone know where it went wrong?

  2. #2
    Fanatic Member
    Join Date
    Dec 2002
    Location
    North Carolina
    Posts
    734

    Re: Problem with a line

    I think you might be misunderstanding the use of the floor function. Take a look at this link, it gives you some inputs and what their output would be when given to the floor function.

    Also, tendered being 29.26 and purchases being 100 would give you a negative number, take a look that if that is not what you intended.

    http://www.cplusplus.com/reference/c...y/cmath/floor/


    "X-mas is 24.Desember you English morons.." - NoteMe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width