MathLib.abs()

MathLib.abs() calculates the absolute value of a number. \[ \text{MathLib.abs}(x) = |x| \]

Specification

MathLib.abs accepts one argument. Any additional arguments will be ignored. The type of the argument should be number. For other argument types see the unary function specification.
  1. MathLib.abs(NaN) = NaN
  2. MathLib.abs(+0) = +0
  3. MathLib.abs(-0) = +0
  4. MathLib.abs(+∞) = +∞
  5. MathLib.abs(-∞) = -∞
  6. otherwise MathLib.abs(x) = absolute value of x

Implementation

MathLib uses the built-in JavaScript implementation Math.abs.

Tests

Categories: unary Function