How to choose from multiple function definition

Hi

I'm trying to use the floor() from <math.h> as follows:

1
2
3
unsigned long a, b, c;

c = floor(a/b);


However I get an error that there are multiple definitions for floor() (ie. double, long double and float data types).

So then I tried using double c; or c = floor(double(a/b));, but neither seems to help.

How do I choose between multiple definition of standard library functions?

Thanks
Both a and b are integers so a/b will do integer division (The result will be an integer). If that is not what you want you can cast one of the sides of the division to a double.
c = floor(double(a) / b);
Note that if the quotient is positive the above will give you the same result as
c = a / b;
Last edited on
awesome, thank you so much
Topic archived. No new replies allowed.