StrictMath.abs(double): This method is available in java.lang.StrictMath class of Java.
Syntax:
double java.lang.StrictMath.abs(double a)
This method takes one argument of type double as its parameter. This method returns the absolute value of a double value.
Note:
1. If the argument is not negative, the argument is returned.
2. If the argument is negative, the negation of the argument is returned.
Special cases:
1. If the argument is positive zero or negative zero, the result is positive zero.
2. If the argument is infinite, the result is positive infinity.
3. If the argument is NaN, the result is NaN.
Parameters: One parameter is required for this method.
a: the argument whose absolute value is to be determined.
Returns: the absolute value of the argument.
Exceptions: NA
Approach
Java
public class StrictMathabsdouble {public static void main(String[] args) {double a = -178.89;System.out.println(StrictMath.abs(a));}}
Output:
178.89
No comments:
Post a Comment