java.math Code Samples
- How do I do math operation for BigDecimal?
- How do I convert BigInteger into another radix number?
- How do I do math operation for BigInteger?
- How do I round a number?
- How do I get the minimum or maximum value between two numbers?
- How do I calculate cube root and square root of a number?
- How do I calculate logarithm?
- How do I use trigonometric calculation methods?
- How do I get signum function of a number?
- How do I raised a number to the power of n?
- How do I get the absolute value of a number?
- How do I get the PI value?
- How do I convert angle from radians to degrees?
Page of 1 |
Prev
|
Next
How do I get signum function of a number?
The code below show you how to get the signum function of a number using the Math.signum() static method call. This method extracts the sign of a real number. If you have a number of x the signum function of x is -1 if x < 0; 0 if x = 0 and 1 if x > 0.
Here is the output of the program:
In double: Signum of 0.0 is 0.0 Signum of -25.0 is -1.0 Signum of 15.0 is 1.0 In float: Signum of 0.0 is 0.0 Signum of -25.0 is -1.0 Signum of 15.0 is 1.0
