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

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

    The PositiveInt16 type represents a positive integer in [1, 2^15). Division (div) uses floor division.

    Type Declaration

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

      Adds two positive integers, returning a + b as a PositiveInt16.

    • div: (x: WithSmallInt, y: ToNonZeroIntWithSmallInt<PositiveInt16>) => PositiveInt16

      Divides two positive integers using floor division (⌊a / b⌋): the result is a / b rounded toward negative infinity, as a PositiveInt16.

    • fromNumber: (x: number) => PositiveInt16

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

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

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

      Type guard that checks if a value is a positive integer in [1, 2^15).

      isPositiveInt16 for usage examples

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

      Returns the largest of the given positive integers.

    • MAX_VALUE: number

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

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

      Returns the smallest of the given positive integers.

    • MIN_VALUE: 1

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

    • mul: (x: WithSmallInt, y: WithSmallInt) => PositiveInt16

      Multiplies two positive integers, returning a * b as a PositiveInt16.

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

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

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

      Generates a random PositiveInt16 within the given range.

      The range is inclusive on both ends.

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

      Subtracts two positive integers, returning a - b as a PositiveInt16.