Function pow

  • Calculates the power of a number to the specified exponent.

    Parameters

    • base: number

      The base number.

    • exponent: number

      The exponent to raise the base to.

    Returns number

    The result of raising the base to the exponent.

    Example

    const result = pow(2, 3);
    console.log(result);
    // Output: 8
  • Calculates the power of a bigint to the specified exponent.

    Parameters

    • base: bigint

      The base bigint.

    • exponent: number

      The exponent to raise the base to.

    Returns bigint

    The result of raising the base to the exponent.

    Example

    const result = pow(BigInt(2), 3);
    console.log(result);
    // Output: 8n
  • Calculates the power of a value to the specified exponent using a custom numerical implementation.

    Type Parameters

    • T

      The type of the base value.

    Parameters

    • base: T

      The base value.

    • exponent: number

      The exponent to raise the base to.

    • Optional numerical: Numerical<T>

      The numerical implementation to use.

    Returns T

    The result of raising the base to the exponent.

    Throws

    Throws an error if no appropriate numerical implementation is provided.

    Example

    const result = pow(2, 3, new NumericalNumber());
    console.log(result);
    // Output: 8

Generated using TypeDoc