s16()

Converts the given number to a signed 16-bit integer (`int16`) by rounding to the nearest whole number and typecasting.

If the number exceeds the range of an `int16` (-32,768 to 32,767), it will wrap due to typecasting.

Syntax

s16(value)

Parameters

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

Return Value

Examples

s16(12345.6);   // returns 12346
s16(-40000);    // returns 25536 (wrap)
s16(70000);     // returns 4464 (wrap)

See also

s8
u8
s16
u16
s32
u32