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

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

    The NegativeInt type represents a negative integer. Division (div) uses floor division.

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

    Type Declaration

    • abs: (x: WithSmallInt<NegativeInt>) => PositiveInt

      Returns the absolute value of a negative integer.

      The result is non-negative and keeps the NegativeInt brand. Note that Math.abs(Number.MIN_SAFE_INTEGER) exceeds Number.MAX_SAFE_INTEGER, so use SafeInt for guaranteed precision.

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

      Adds two negative integers, returning a + b as a NegativeInt.

    • fromNumber: (x: number) => NegativeInt

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

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

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

      Type guard that checks if a value is a negative integer.

      isNegativeInt for usage examples

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

      Returns the largest of the given negative integers.

    • MAX_VALUE: -1

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

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

      Returns the smallest of the given negative integers.

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

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

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

      Generates a random NegativeInt within the given range.

      The range is inclusive on both ends.

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

      Subtracts two negative integers, returning a - b as a NegativeInt.