How do I compute the remainder of the division of two floats?
How about a-floor(a/b)*b - presuming a and b both positive?
You could say that "remainder" is not a proper concept for float divisions, but I'll leave that to your own judgment.
Use fmod, which computes the floating point modulus.
double remainder = fmod(a_double, another_double);
If you want to use float instead of double you'd use fmodf instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With