u8()

Converts the given number to an unsigned 8-bit integer (`uint8`) by rounding to the nearest whole number and typecasting.

If the number exceeds the range of a `uint8` (0 to 255), it will wrap due to typecasting.

Syntax

u8(value)

Parameters

Parameter Type Description
value Number Numeric value to convert to uint8.

Return Value

Examples

u8(10.7);   // returns 11
u8(-1);     // returns 255 (wrap)
u8(300);    // returns 44 (wrap)

See also

s8
u8
s16
u16
s32
u32