Java Utililty Methods Float Number Mod

List of utility methods to do Float Number Mod

Description

The list of methods to do Float Number Mod are organized into topic(s).

Method

doublefmod(double a, double b)
fmod
double mod = a % b;
if (mod < 0) {
    mod += b;
return mod;
doublefmod(double a, double b)
Computes the floating-point remainder of a/b.
int result = (int) Math.floor(a / b);
return a - result * b;
doubleFMod(double x, double y)
C fmod function.
return x - Math.floor(x / y) * y;
floatfmodf(Float float1, float float2)
fmodf
return float1 % float2;
doublefmodulo(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;
floatmod(final float a, final float b)
mod
int n = (int) (a / b);
float aa = a - n * b;
if (aa < 0) {
    aa += b;
return aa;
floatmod(final float a, final float mod)
An equivalent to % for float
final float b = a - mod * (int) (a / mod);
if (b >= 0)
    return b;
else
    return b + mod;
floatmod(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;
floatmod(float a, float b)
Return a mod b.
int n = (int) (a / b);
a -= n * b;
if (a < 0)
    return a + b;
return a;
floatmod(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;