Function sqrt

  • Calculates the square root of a given number.

    Parameters

    • x: number

      The number for which to calculate the square root.

    Returns number

    The square root of the given number.

    Example

    sqrt(9);     // Returns 3
    sqrt(100); // Returns 10
  • Calculates the square root of a given bigint value.

    Parameters

    • x: bigint

      The bigint value for which to calculate the square root.

    Returns bigint

    The square root of the given value.

    Example

    sqrt(9n);     // Returns 3n
    sqrt(100n); // Returns 10n
  • Calculates the square root of a given value using the provided numerical implementation.

    Type Parameters

    • T

      The type of the value.

    Parameters

    • x: T

      The value for which to calculate the square root.

    • Optional numerical: Numerical<T>

      The numerical implementation to use. Defaults to NumericalNumber if not provided.

    Returns T

    The square root of the given value.

    Throws

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

    Example

    sqrt(9);   // Returns 3
    sqrt(9n); // Returns 3n
    sqrt(9, new Numerical<number>()); // Where Numerical<number>() is an implementation for numbers.

Generated using TypeDoc