floor() and ceil()

Good day.
I would be grateful if someone explained why floor() and ceil() functions (math.h) return double or float values. As far as I understand they just round up the parameter and by definition return an int in any case.
???
Last edited on
That's because float's range is larger than the int's range.
I understand that. But these functions will never return a float (or am I missing something?)
If you use the ones from <cmath>, it will return a float if you put in a float.
http://www.cplusplus.com/reference/clibrary/cmath/floor/

Last edited on
Well, the range of a double is even greater than the range of a float, but even a simple float can represent the integer 340282346638528859811704183484516925440, which is too big to fit in a int, or even in an unsigned long long int.
Topic archived. No new replies allowed.