- 1
Whats the point of math.abs()
Whats the point of math.abs()? example; int y=math.abs(10);//why say this when i could just say int y=10; ?
2 Respostas
+ 14
The function returns the absolute value of the received parameter. You use it when you want to convert negative values to their unsigned (positive) values.
+ 2
Its because you can also pass in variables. And if you want to retrieve the positive value and you cant make sure that the variable wont be negative, then you do Math.abs(variable);
Of course for your given example there is no point for that