How does (floor) actually work in C? According to techonthenet . com ,
In the C Programming Language, the floor function returns the largest integer that is smaller than or equal to x (ie: rounds downs the nearest integer).
After entering value 4.2 into get_float(), I use floor(4.2 * 100), to turn them into cents and remove decimal places and make it into an integer.
However, I am perplexed why entering the value specifically 4.2 will return a different value for both floor(4.2 * 100), and floor(4.2 * 1000 / 10)? Does this have something to do with imprecision?
See image: When variable entered as 4.2, floor produces different values
Btw, I am totally new to this just started CS50 on edx, and trying out the last exercise of week 1's lesson.. would also love any comments on other parts of the code. More info on the problem here: http://docs.cs50.net/problems/greedy/greedy.html