The math.abs() function takes one argument: the number whose absolute value you want to find out!
The absolute value of a number is an important concept to know if your calculations and estimations are accurate. This function returns the magnitude (or distance from positive) in integer form. The output should not have any extra words added to it.
Math.abs(-100) // will return 100 math.abs(0) // will return 0 math.abs("hahahah")//will return NaN, because the string is not a number so can't be used in calculations
What happens If argument double or float type:
- A positive zero or negative zero is equivalent to a regular number with the opposite sign. A result of – 0 will be converted into 0;
- Infinite processes lead to positive infinity.
- If the argument is NaN, then, of course, the result will also be NaN.
There are many different ways to use Math.abs() to do various things, depending on what you need it for. It’s also important not to forget that this function can only be applied with numbers and will return an absolute value depending on the sign of the input argument. If you have any questions about implementing these functions in your work, please don’t hesitate to contact us! Our experts are always happy to help!
Follow us on Facebook
|Full support 45||Full support 12||Full support|
|WebView Android||Chrome Android||Firefox Android||Opera Android||Safari on iOS||Samsung Internet|