ts-data-forge
    Preparing search index...
    NegativeInt: {
        abs: (x: WithSmallInt<NegativeInt>) => PositiveInt;
        add: (x: WithSmallInt, y: WithSmallInt) => NegativeInt;
        clamp: (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 arithmetic operations for negative integers.

    NegativeInt represents integers that are strictly less than zero (<= -1). Operations that stay within the negative integers (such as add) clamp their results to the valid range, while operations whose result leaves the set (mul, div, abs) are typed to reflect the actual sign of the result.

    Type Declaration

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

      Returns the absolute value of a negative integer.

      The negative integer.

      The absolute value as a PositiveInt.

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

      Adds two negative integers.

    • clamp: (x: number) => NegativeInt

      Clamps a number to the negative integer range.

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

      Type guard to check if a value is a NegativeInt.

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

      Returns the larger of two negative integers.

    • ReadonlyMAX_VALUE: -1

      The maximum value for a negative integer.

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

      Returns the smaller of two negative integers.

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

      Raises a negative integer to the power of another negative integer.

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

      Generates a random NegativeInt value within the valid range.

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

      Subtracts one negative integer from another.

      The mathematical result can be positive, so it is clamped to the negative integer range (maximum -1).