java.math Code Samples
Page 2 of 2 |
Prev
|
Next
How do I get the absolute value of a number?
The example below show you how to get the absolute value of a number. To get the absolute value or the abs value of a number we use the Math.abs() method call. The Math.abs() method is an overloaded that can accept value in type of double, float, int or long.
The code snippet above print the following result:
Absolute value in double: 10.0 Absolute value in float : 10.0 Absolute value in int : 10 Absolute value in long : 10