<type>_TO_BOOL

This IEC operator converts from a different data type to the data type BOOL.

Syntax: <Data type>_TO_BOOL

The result is TRUE if the operand is not equal to 0. The result is FALSE if the operand equals 0. With the data type STRING the result is TRUE if the operand is TRUE, otherwise the result is FALSE.

Samples:

ST code

Result

bVar := BYTE_TO_BOOL(2#11010101);

TRUE

bVar := INT_TO_BOOL(0);

FALSE

bVar := TIME_TO_BOOL(T#5ms);

TRUE

bVar := STRING_TO_BOOL('TRUE');

TRUE

FBD code

Result

<type>_TO_BOOL 1:

TRUE

<type>_TO_BOOL 2:

FALSE

<type>_TO_BOOL 3:

TRUE

<type>_TO_BOOL 4:

TRUE

See also: