Javatpoint Logo
Javatpoint Logo

Java Math.abs() method

The java.lang.Math.abs() method returns the absolute (Positive) value of a int value. This method gives the absolute value of the argument. The argument can be int, double, long and float.

Syntax:

Parameters:

Return:

  • If we provide positive or negative value as argument, this method will result positive value.
  • If the argument is Infinity, this method will result Positive Infinity.
  • If the argument is NaN, this method will return NaN.
  • If the argument is equal to the value of Integer.MIN_VALUE or Long.MIN_VALUE, the most negative representable int value or long value, the result is that same value, which is negative.

Example 1:

Test it Now

Output:

78
48
-2147483648

Example 2:

Test it Now

Output:

47.63
894.37
Infinity

Example 3:

Test it Now

Output:

73.02
428.0

Example 4:

Test it Now

Output:

78730343
4839233
-9223372036854775808

Next TopicJava Math




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA