Const
Returns the absolute value of an integer.
The result is always non-negative and maintains the Int brand. Note that Math.abs(Number.MIN_SAFE_INTEGER) exceeds Number.MAX_SAFE_INTEGER, so use SafeInt for guaranteed precision.
Adds two integers.
Divides two integers using floor division.
Performs mathematical floor division: ⌊a / b⌋
. The result is always an
integer, rounding toward negative infinity.
Type guard that checks if a value is an integer.
isInt for usage examples
Readonly
max: (...values: readonly WithSmallInt<Int, 40>[]) => IntReturns the maximum value from a list of integers.
Readonly
min: (...values: readonly WithSmallInt<Int, 40>[]) => IntReturns the minimum value from a list of integers.
Multiplies two integers.
Raises an integer to a power.
Generates a random integer within the specified range (inclusive).
The range is inclusive on both ends, so random(1, 6) can return any of: 1, 2, 3, 4, 5, or 6.
Subtracts two integers.
Namespace providing type-safe operations for Int branded types.
The Int type represents any integer value (no fractional component) without range restrictions. All operations preserve the integer constraint, using floor division for division operations.
Unlike SafeInt, Int allows values outside the safe integer range (±2^53 - 1), but be aware that very large integers may lose precision in JavaScript's number type.