@metreeca/core - v0.9.22
    Preparing search index...

    Function div

    • Internal

      Divides a numeric value by a divisor.

      The quotient keeps the numeric type of the dividend. A number dividend divides as an IEEE 754 double, yielding an infinity on a zero divisor rather than reporting an error. A bigint dividend yields a bigint quotient: as no fractional bigint can carry the remainder, the exact quotient is rounded to the nearest integer, halves away from zero, whatever the sign of the operands.

      Dividing a bigint requires a finite integral divisor, as the divisor is converted to a bigint first, and a non-zero one, as no bigint stands for an infinity.

      Type Parameters

      • V extends number | bigint

        The numeric type of the dividend and of the quotient

      Parameters

      • x: V

        The dividend

      • y: number

        The divisor

      Returns V

      The quotient of x by y, as an IEEE 754 double for a number dividend, or rounded to the nearest integer, halves away from zero, for a bigint dividend

      If x is a bigint and y is not a finite integer or is 0