Math.absInt()
Signature
int absInt (int a)
Description
Returns the absolute value of an int value.
If the argument is not negative, the argument is returned.
If the argument is negative, the negation of the argument is returned.
Note that if the argument is equal to the value of
Integer.MIN_VALUE, the most negative representable
int value, the result is that same value, which is
negative.
Parameters
Name | Type | Description |
a | int | The argument whose absolute value is to be determined. |
Returns
Type | Description |
int | The absolute value of the argument. |
See Also
java.lang.Integer#MIN_VALUE
Example
String result = String.valueOfInt (Math.absInt (-34));
Result is: result contains: "34"