Function createBig

  • Creates a new Big instance from the given value. If the value is already a Big instance, it returns the value itself. Use this function instead of the Big constructor to create a Big instance from a value.

    Parameters

    • value: BigObject | Big

      The value to create the Big instance from.

    Returns Big

    • A new Big instance.
  • Creates a new Big instance from the given value. If the value is already a Big instance, it returns the value itself. Use this function instead of the Big constructor to create a Big instance from a value.

    Parameters

    • value: PossibleNumber

      The value to create the Big instance from. It Can be a number, string, or BigInt.

    Returns Big

    • A new Big instance.
  • Creates a new Big instance from the given value. If the value is already a Big instance, it returns the value itself. Use this function instead of the Big constructor to create a Big instance from a value.

    Parameters

    • value: PossibleNumber

      The value to create the Big instance from. Can be a number, string, or BigInt.

    • Optional scale: string | number

      The scale for the value (optional), representing the number of decimal places. If scale provided and value has a fractional part, the fractional part will be removed.

    Returns Big

    • A new Big instance.

    Example

    const big1 = createBig(123.456); // 123.456
    const big2 = createBig("123.456"); // 123.456
    const big3 = createBig(123.456, 2); // 1.23, because the scale is 2 and it removes the fractional part

Generated using TypeDoc