Function abs

  • Returns the absolute value of a number.

    Parameters

    • x: number

      The number to calculate the absolute value of.

    Returns number

    The absolute value of the number.

    Example

    abs(-5);   // Returns 5
    
  • Returns the absolute value of a bigint.

    Parameters

    • x: bigint

      The bigint to calculate the absolute value of.

    Returns bigint

    The absolute value of the bigint.

    Example

    abs(-5n);   // Returns 5n
    
  • Returns the absolute value of a number of type T.

    Type Parameters

    • T

    Parameters

    • x: T

      The number to calculate the absolute value of.

    • Optional numerical: Numerical<T>

      An instance of Numerical interface for the numeric type T.

    Returns T

    The absolute value of the number of type T.

    Typeparam

    T - The data type for the numeric operations.

    Throws

    If x's type is neither number nor bigint, and no Numerical instance was provided.

    Example

    abs(-5);                        // Returns 5
    abs(-5n); // Returns 5n
    abs(-5, new Numerical<number>()); // Where Numerical<number>() is an implementation for numbers.

Generated using TypeDoc