ts-data-forge
    Preparing search index...

    Function div

    • Performs type-safe division with compile-time zero-check.

      This function leverages TypeScript's type system to prevent division by zero at compile time. The divisor must be typed as NonZeroNumber or a non-zero numeric literal.

      Parameters

      • a: number

        The dividend

      • b:
            | 1
            | 2
            | 3
            | 32
            | NonZeroNumber
            | 4
            | 5
            | 6
            | 7
            | 8
            | 9
            | 11
            | 10
            | 24
            | 14
            | 34
            | 12
            | 13
            | 15
            | 16
            | 17
            | 18
            | 19
            | 20
            | 21
            | 22
            | 23
            | 25
            | 26
            | 27
            | 28
            | 29
            | 30
            | 31
            | 33
            | 35
            | 36
            | 37
            | 38
            | 39
            | -1
            | -2
            | -3
            | -32
            | -4
            | -5
            | -6
            | -7
            | -8
            | -9
            | -11
            | -10
            | -24
            | -14
            | -34
            | -12
            | -13
            | -15
            | -16
            | -17
            | -18
            | -19
            | -20
            | -21
            | -22
            | -23
            | -25
            | -26
            | -27
            | -28
            | -29
            | -30
            | -31
            | -33
            | -35
            | -36
            | -37
            | -38
            | -39
            | -40

        The divisor (must be non-zero, enforced by types)

      Returns number

      The quotient of a / b