Implement the Math#signum method

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin 2013-11-02 00:23:42 -05:00
parent f8028c9864
commit 6a7c03aef9

View File

@ -75,6 +75,14 @@ public final class Math {
return (int) Math.floor(v + 0.5);
}
public static double signum(double d) {
return d > 0 ? +1.0 : d < 0 ? -1.0 : 0;
}
public static float signum(float f) {
return f > 0 ? +1.0f : f < 0 ? -1.0f : 0;
}
public static double random() {
return random.nextDouble();
}