Readonlyadd: (x: WithSmallInt<SafeUint, 40>, y: WithSmallInt<SafeUint, 40>) => SafeUintAdds two non-negative safe integers, returning a + b as a SafeUint.
Readonlydiv: (Divides two non-negative safe integers using floor division (⌊a / b⌋):
the result is a / b rounded toward negative infinity, as a SafeUint.
ReadonlyfromNumber: (x: number) => SafeUintConverts an arbitrary number into a SafeUint, rounding to the nearest
integer and saturating the result into the range [MIN_VALUE, MAX_VALUE].
Unlike asSafeUint, this is total: out-of-range inputs are clamped to the
nearest representable SafeUint instead of throwing.
Readonlyis: (a: number) => a is SafeUintType guard that checks if a value is a non-negative safe integer.
isSafeUint for usage examples
Readonlymax: (...values: readonly WithSmallInt<SafeUint, 40>[]) => SafeUintReturns the largest of the given non-negative safe integers.
ReadonlyMAX_VALUE: SafeUintThe largest value representable as SafeUint (the upper saturation target
of fromNumber).
Readonlymin: (...values: readonly WithSmallInt<SafeUint, 40>[]) => SafeUintReturns the smallest of the given non-negative safe integers.
ReadonlyMIN_VALUE: 0The smallest value representable as SafeUint (the lower saturation target
of fromNumber).
Readonlymul: (x: WithSmallInt<SafeUint, 40>, y: WithSmallInt<SafeUint, 40>) => SafeUintMultiplies two non-negative safe integers, returning a * b as a
SafeUint.
Readonlypow: (x: WithSmallInt<SafeUint, 40>, y: WithSmallInt<SafeUint, 40>) => SafeUintRaises a to the power b, returning a ** b as a SafeUint (floored to
an integer).
Readonlyrandom: (min?: WithSmallInt<SafeUint, 40>, max?: WithSmallInt<SafeUint, 40>) => SafeUintGenerates a random SafeUint within the given range.
The range is inclusive on both ends.
Readonlysub: (x: WithSmallInt<SafeUint, 40>, y: WithSmallInt<SafeUint, 40>) => SafeUintSubtracts two non-negative safe integers, returning a - b as a
SafeUint.
Namespace providing type-safe operations for the
SafeUintbranded type.The
SafeUinttype represents a non-negative safe integer. Division (div) uses floor division.