Calculating the value of a number in java

I forgot the function in Java to calculate the value of an integer. please, help..

| 5 | = +5 = 5

| -5 | = +5 = 5

therefore, if a - b - x

mag (a - b) represents the x number of posts.

+4
source share
4 answers

I believe you are looking for Math.abs () . Using this function:

5 = Math.abs(5) = Math.abs(-5) 
+13
source

Try Math.abs .

 abs(-4) = 4; abs(5) = 5; 
+3
source

The function in the Math library is called abs() (short for "absolute value").

+2
source

Math.abs () is the function you are looking for.

+2
source

Source: https://habr.com/ru/post/1401431/


All Articles