ts-fortress
    Preparing search index...

    Variable NonZeroUint16

    NonZeroUint16: {
        add: (
            x: WithSmallInt<PositiveUint16, 40>,
            y: WithSmallInt<PositiveUint16, 40>,
        ) => PositiveUint16;
        fromNumber: (x: number) => PositiveUint16;
        is: (a: number) => a is PositiveUint16;
        max: (
            ...values: readonly WithSmallInt<PositiveUint16, 40>[],
        ) => PositiveUint16;
        MAX_VALUE: number;
        min: (
            ...values: readonly WithSmallInt<PositiveUint16, 40>[],
        ) => PositiveUint16;
        MIN_VALUE: 1;
        mul: (
            x: WithSmallInt<PositiveUint16, 40>,
            y: WithSmallInt<PositiveUint16, 40>,
        ) => PositiveUint16;
        pow: (
            x: WithSmallInt<PositiveUint16, 40>,
            y: WithSmallInt<PositiveUint16, 40>,
        ) => PositiveUint16;
        random: (
            min?: WithSmallInt<PositiveUint16, 40>,
            max?: WithSmallInt<PositiveUint16, 40>,
        ) => PositiveUint16;
    }

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

    The NonZeroUint16 type represents a non-zero integer in [1, 2^16). Division (div) uses floor division.

    Type Declaration

    • Readonlyadd: (
          x: WithSmallInt<PositiveUint16, 40>,
          y: WithSmallInt<PositiveUint16, 40>,
      ) => PositiveUint16

      Adds two non-zero integers, returning a + b as a NonZeroUint16.

    • ReadonlyfromNumber: (x: number) => PositiveUint16

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

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

    • Readonlyis: (a: number) => a is PositiveUint16

      Type guard that checks if a value is a non-zero integer in [1, 2^16).

      isNonZeroUint16 for usage examples

    • Readonlymax: (...values: readonly WithSmallInt<PositiveUint16, 40>[]) => PositiveUint16

      Returns the largest of the given non-zero integers.

    • ReadonlyMAX_VALUE: number

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

    • Readonlymin: (...values: readonly WithSmallInt<PositiveUint16, 40>[]) => PositiveUint16

      Returns the smallest of the given non-zero integers.

    • ReadonlyMIN_VALUE: 1

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

    • Readonlymul: (
          x: WithSmallInt<PositiveUint16, 40>,
          y: WithSmallInt<PositiveUint16, 40>,
      ) => PositiveUint16

      Multiplies two non-zero integers, returning a * b as a NonZeroUint16.

    • Readonlypow: (
          x: WithSmallInt<PositiveUint16, 40>,
          y: WithSmallInt<PositiveUint16, 40>,
      ) => PositiveUint16

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

    • Readonlyrandom: (
          min?: WithSmallInt<PositiveUint16, 40>,
          max?: WithSmallInt<PositiveUint16, 40>,
      ) => PositiveUint16

      Generates a random NonZeroUint16 within the given range.

      The range is inclusive on both ends.