Skip to content

uint

Casts an expression to an unsigned integer.

uint(x:number|string, base=int) -> uint

The uint function casts the provided value x to an unsigned integer. Non-integer values are truncated.

The input to convert.

Base (radix) to parse a string as. Can be 10 or 16.

If 16, the string inputs may be optionally prefixed by 0x or 0X, e.g., 0x134.

Defaults to 10.

Cast a floating-point number to an unsigned integer

Section titled “Cast a floating-point number to an unsigned integer”
from {x: uint(4.2)}
{x: 4}
from {x: uint("0x42", base=16)}
{x: 66}

int, float, time, string, ip