| Return | Method | Summary |
|---|---|---|
| static double | signum(double d) | Returns the sign of d; zero if the argument is zero, 1.0 if the argument is greater than zero, -1.0 if the argument is less than zero. |
| static float | signum(float f) | Returns the signum of f; zero if the argument is zero, 1.0f if the argument is greater than zero, -1.0f if the argument is less than zero. |
public class Main {
public static void main(String[] args) {
System.out.println(Math.signum(1.2));
System.out.println(Math.signum(-1.2));
}
}
The output:
1.0
-1.0java2s.com | | Contact Us | Privacy Policy |
| Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
| All other trademarks are property of their respective owners. |