Class: MathUtils
Defined in: utils/MathUtils.ts:5
Utility methods for safe 32-bit unsigned integer arithmetic and numeric clamping
Constructors
Constructor
new MathUtils():
MathUtils
Returns
MathUtils
Methods
align()
staticalign(n,m):number
Defined in: utils/MathUtils.ts:28
Aligns a positive number n to the next multiple of m
If n is already a multiple of m, returns n.
Otherwise, returns the smallest multiple of m that is greater than n.
Parameters
n
number
The non-negative number to align
m
number
The strictly positive multiple to align to
Returns
number
The aligned number
clamp()
staticclamp(value,min,max):number
Defined in: utils/MathUtils.ts:14
Clamps a value to the range [min, max]
Parameters
value
number
The value to clamp
min
number
Lower bound
max
number
Upper bound
Returns
number
The clamped value
safeAnd()
staticsafeAnd(a,b):number
Defined in: utils/MathUtils.ts:47
Performs a bitwise AND, returning an unsigned 32-bit result
Parameters
a
number
First operand
b
number
Second operand
Returns
number
safeLeftShift()
staticsafeLeftShift(value,shift):number
Defined in: utils/MathUtils.ts:98
Performs a left shift, returning an unsigned 32-bit result
Parameters
value
number
The value to shift
shift
number
Number of bit positions to shift
Returns
number
safeNot()
staticsafeNot(a):number
Defined in: utils/MathUtils.ts:85
Performs a bitwise NOT, returning an unsigned 32-bit result
Parameters
a
number
The operand
Returns
number
safeOr()
staticsafeOr(a,b):number
Defined in: utils/MathUtils.ts:60
Performs a bitwise OR, returning an unsigned 32-bit result
Parameters
a
number
First operand
b
number
Second operand
Returns
number
safeRightShift()
staticsafeRightShift(value,shift):number
Defined in: utils/MathUtils.ts:111
Performs an unsigned right shift
Parameters
value
number
The value to shift
shift
number
Number of bit positions to shift
Returns
number
safeXor()
staticsafeXor(a,b):number
Defined in: utils/MathUtils.ts:73
Performs a bitwise XOR, returning an unsigned 32-bit result
Parameters
a
number
First operand
b
number
Second operand
Returns
number