Table of Contents

CWORD

The CWORD() function converts its argument to an unsigned 16-bit value.

Function header

DECLARE FUNCTION CWORD AS WORD (number AS BYTE) SHARED STATIC INLINE
DECLARE FUNCTION CWORD AS WORD (number AS INT) OVERLOAD SHARED STATIC INLINE
DECLARE FUNCTION CWORD AS WORD (number AS LONG) OVERLOAD SHARED STATIC INLINE
DECLARE FUNCTION CWORD AS WORD (number AS FLOAT) OVERLOAD SHARED STATIC INLINE

If the argument is a LONG, the number will be truncated to 16-bits. If the argument is a FLOAT, it will be rounded and then converted to WORD.

Examples

PRINT CWORD(-1) : REM outputs 65535
PRINT CWORD(1001.4) : REM outputs 1001