<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 |
---|---|
TRUE | |
FALSE | |
TRUE | |
TRUE |
See also:
- Data types > BOOL