I want to divide two integers, s and t and then round down the answer to produce p, is this the correct code and is there a better way to do it?
Code:p=(int)(floor((float)s/(float)t));
I want to divide two integers, s and t and then round down the answer to produce p, is this the correct code and is there a better way to do it?
Code:p=(int)(floor((float)s/(float)t));
Hi,
There is one function called ceil defined in math.h. You can use it.
p=ceil((float)s/(float)t));//p should be double datatype. I am assuming s ant t are int's.
Saravanan.T.S.
Beginner.