The list of methods to do Float Number Mod are organized into topic(s).
double
fmod(double a, double b) Computes the floating-point remainder of a/b.
int result = (int) Math.floor(a / b);
return a - result * b;
double
fmodulo(double v1, double v2) Returns the remainder of the division v1/v2 .
if (v1 >= 0)
return (v1 < v2) ? v1 : v1 % v2;
double tmp = v1 % v2 + v2;
return (tmp == v2) ? 0. : tmp;
float
mod(float a, float b) Calculates x modulo y.
if (a < 0) {
return a + (float) Math.ceil(-a / b) * b;
} else if (a >= b) {
return a - (float) Math.floor(a / b) * b;
} else {
return a;
float
mod(float a, float b) Return a mod b.
int n = (int) (a / b);
a -= n * b;
if (a < 0)
return a + b;
return a;
float
mod(float a, float b) Calculates a mod b in a way that respects negative values (for example, mod(-1, 5) == 4 , rather than -1 ).
return (a % b + b) % b;