Returns the non-negative remainder of x / m.
x The operand.
x
m The modulus.
m
static double mod(double x, double m) => ((x % m) + m) % m;