Math.abs

Math.abs

Class Overview | Class Members | This Package | All Packages

Syntax 1
public static int abs( int a )
Parameters
a
an int value.
Returns
the absolute value of the argument.
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.

See Also
MIN_VALUE



Syntax 2
public static long abs( long a )
Parameters
a
a long value.
Returns
the absolute value of the argument.
Description
Returns the absolute value of a long 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 Long.MIN_VALUE, the most negative representable long value, the result is that same value, which is negative.

See Also
MIN_VALUE



Syntax 3
public static float abs( float a )
Parameters
a
a float value.
Returns
the absolute value of the argument.
Description
Returns the absolute value of a float value. If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned.



Syntax 4
public static double abs( double a )
Parameters
a
a double value.
Returns
the absolute value of the argument.
Description
Returns the absolute value of a double value. If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned.