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

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

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

    Type Declaration

    • abs: (x: WithSmallInt<NegativeSafeInt>) => PositiveSafeInt

      Returns the absolute value of a negative safe integer.

      The result is non-negative and keeps the NegativeSafeInt brand.

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

      Adds two negative safe integers, returning a + b as a NegativeSafeInt.

    • fromNumber: (x: number) => NegativeSafeInt

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

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

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

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

      isNegativeSafeInt for usage examples

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

      Returns the largest of the given negative safe integers.

    • MAX_VALUE: -1

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

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

      Returns the smallest of the given negative safe integers.

    • MIN_VALUE: number

      The smallest value representable as NegativeSafeInt (the lower saturation target of fromNumber).

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

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

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

      Generates a random NegativeSafeInt within the given range.

      The range is inclusive on both ends.

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

      Subtracts two negative safe integers, returning a - b as a NegativeSafeInt.