How to calculate the remainder of division of two float s?
float
How about a-floor(a/b)*b - assuming a and b both positive?
a-floor(a/b)*b
a
b
We can say that the βremainderβ is not the right concept for floating divisions, but I will leave it to my own opinion.
Use fmod , which computes a floating point module.
fmod
double remainder = fmod(a_double, another_double);
If you want to use float instead of double , use fmodf .
double
fmodf