Skip to content

Clamp

Represents a range of possible integers by providing a minimum and maximum, then encoding / decoding the equivalent of math.clamp(input, minimum, maximum).

function light.datatypes.clamp

Shared Synchronous
1
2
3
4
function clamp(
    minimum: number,
    maximum: number
): (Datatype<number>)

Size

Will use the minimum number of bytes possible to represent the range of possible numbers:

math.abs(maximum - minimum) < n Size
n = 256 1 Byte
n = 65,536 2 Bytes
n = 16,777,216 3 Bytes
n = 4,294,967,296 4 Bytes
n = 2 ^ 40 5 Bytes
n = 2 ^ 48 6 Bytes
n = 2 ^ 56 7 Bytes