ts-data-forge
    Preparing search index...
    NonPositiveInt: {
        add: (x: WithSmallInt, y: WithSmallInt) => NonPositiveInt;
        fromNumber: (x: number) => NonPositiveInt;
        is: (a: number) => a is NonPositiveInt;
        max: (...values: readonly WithSmallInt<NonPositiveInt>[]) => NonPositiveInt;
        MAX_VALUE: 0;
        min: (...values: readonly WithSmallInt<NonPositiveInt>[]) => NonPositiveInt;
        pow: (x: WithSmallInt, y: WithSmallInt) => NonPositiveInt;
        random: (
            min?: WithSmallInt<NonPositiveInt>,
            max?: WithSmallInt<NonPositiveInt>,
        ) => NonPositiveInt;
        sub: (x: WithSmallInt, y: WithSmallInt) => NonPositiveInt;
    }

    Namespace providing type-safe operations for the NonPositiveInt branded type.

    The NonPositiveInt type represents a non-positive integer. Division (div) uses floor division.

    Unlike SafeInt, NonPositiveInt allows values outside the safe integer range (±2^53 − 1), so very large magnitudes may lose precision in JavaScript's number type.

    Type Declaration

    • add: (x: WithSmallInt, y: WithSmallInt) => NonPositiveInt

      Adds two non-positive integers, returning a + b as a NonPositiveInt.

    • fromNumber: (x: number) => NonPositiveInt

      Converts an arbitrary number into a NonPositiveInt, rounding to the nearest integer and saturating the result into the range [MIN_VALUE, MAX_VALUE].

      Unlike asNonPositiveInt, this is total: out-of-range inputs are clamped to the nearest representable NonPositiveInt instead of throwing.

    • is: (a: number) => a is NonPositiveInt

      Type guard that checks if a value is a non-positive integer.

      isNonPositiveInt for usage examples

    • Readonlymax: (...values: readonly WithSmallInt<NonPositiveInt>[]) => NonPositiveInt

      Returns the largest of the given non-positive integers.

    • MAX_VALUE: 0

      The largest value representable as NonPositiveInt (the upper saturation target of fromNumber).

    • Readonlymin: (...values: readonly WithSmallInt<NonPositiveInt>[]) => NonPositiveInt

      Returns the smallest of the given non-positive integers.

    • pow: (x: WithSmallInt, y: WithSmallInt) => NonPositiveInt

      Raises a to the power b, returning a ** b as a NonPositiveInt (floored to an integer).

    • random: (
          min?: WithSmallInt<NonPositiveInt>,
          max?: WithSmallInt<NonPositiveInt>,
      ) => NonPositiveInt

      Generates a random NonPositiveInt within the given range.

      The range is inclusive on both ends.

    • sub: (x: WithSmallInt, y: WithSmallInt) => NonPositiveInt

      Subtracts two non-positive integers, returning a - b as a NonPositiveInt.