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/