List of utility methods to do Number Sign
int | signum(float val) signum return (int) Math.signum(val); |
int | signum(int a) signum if (a == 0) return 0; return a < 0 ? -1 : 1; |
int | signum(int v) Returns the sign of a number: either -1, 0 or 1. return v < 0 ? -1 : v > 0 ? 1 : 0;
|
int | signum(long diff) Collapse number down to +1 0 or -1 depending on sign. if (diff > 0) return 1; if (diff < 0) return -1; else return 0; |
int | signum(long l) signum if (l > 0) { return 1; } else if (l < 0) { return -1; } else { return 0; |
int | signum(long number) signum if (number < 0) return -1; else if (number == 0) return 0; else return 1; |
double | signumEps(double val, double eps) Signum functions with epsilon for floating point imprecision if (val < eps && val > -eps) return 0; else return Math.signum(val); |