Readonlyabs: (x: WithSmallInt<Int, 40>) => IntersectBrand<Int, NonNegativeNumber>Returns the absolute value of an integer.
The result is non-negative and keeps the Int brand. Note that
Math.abs(Number.MIN_SAFE_INTEGER) exceeds Number.MAX_SAFE_INTEGER, so
use SafeInt for guaranteed precision.
Readonlyadd: (x: WithSmallInt<Int, 40>, y: WithSmallInt<Int, 40>) => IntAdds two integers, returning a + b as an Int.
Readonlydiv: (Divides two integers using floor division (⌊a / b⌋): the result is a / b rounded toward negative infinity, as an Int.
Readonlyis: (a: number) => a is IntType guard that checks if a value is an integer.
isInt for usage examples
Readonlymax: (...values: readonly WithSmallInt<Int, 40>[]) => IntReturns the largest of the given integers.
Readonlymin: (...values: readonly WithSmallInt<Int, 40>[]) => IntReturns the smallest of the given integers.
Readonlymul: (x: WithSmallInt<Int, 40>, y: WithSmallInt<Int, 40>) => IntMultiplies two integers, returning a * b as an Int.
Readonlypow: (x: WithSmallInt<Int, 40>, y: WithSmallInt<Int, 40>) => IntRaises a to the power b, returning a ** b as an Int (floored to an
integer).
Readonlyrandom: (min?: WithSmallInt<Int, 40>, max?: WithSmallInt<Int, 40>) => IntGenerates a random Int within the given range.
The range is inclusive on both ends.
Readonlysub: (x: WithSmallInt<Int, 40>, y: WithSmallInt<Int, 40>) => IntSubtracts two integers, returning a - b as an Int.
Namespace providing type-safe operations for the
Intbranded type.The
Inttype represents an integer. Division (div) uses floor division.Unlike
SafeInt,Intallows values outside the safe integer range (±2^53 − 1), so very large magnitudes may lose precision in JavaScript'snumbertype.