Math.abs() (Function)

The absolute value of a positive or negative number.


ECMAScript edition - 2
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Netscape Enterprise Server version - 2.0
Opera - 3.0
Property/method value type:Number primitive
JavaScript syntax:-Math.abs(aValue)
Argument list:aValueSome meaningful numeric value.

This function returns the absolute value of the argument.

The absolute value of a number is its distance from zero.

In general, the result has the same magnitude as the argument but always has a positive sign.

Special boundary conditions that affect the results are:

negative infinitypositive infinity

On some implementations, the absolute value of the most negative integer number may not be representable in the positive range.

This is not the same as Number.MIN_VALUE and Number.MAX_VALUE. They describe the largest and smallest possible positive floating point values.


Example code:

   for(myEnum = 1.5; myEnum > -2; myEnum -= 0.1)
      document.write(myEnum + " " + Math.abs(myEnum) + "<BR>");

See also:Integer arithmetic, Integer-value-remainder, Math object, Math.ceil(), Math.floor(), Type conversion


ECMA 262 edition 2 - section -

ECMA 262 edition 3 - section -