Documentation

Implicit conversions for elementary types

Here are described conversions, which take place in an expression automatically. Generally, their implementation is the same as the implementation of explicit conversions.

User must be aware of these rules at least when he needs to restrict computation on the VM's stack to be 32/64 bit.

When passing parameters to overloaded functions or when in an operator expression there meet operands of the different types, implicit conversions are determined by the rules which follow:

  • ANY_INT -> ANY_REAL
  • SINT, USINT, INT, UINT, DINT, UDINT -> REAL, LREAL
  • LINT, ULINT -> LREAL
  • ANY_INT -> ANY_BIT, when they have the same type length or target bit string is longer (ie. it is possible do DINT, LINT -> LWORD, but not LINT -> DWORD)
  • ANY_BIT -> ANY_INT, when they have the same type length or target int type is longer (ie. it is possible do DWORD, LWORD -> LINT, but not LWORD -> DINT)
  • ANY_BIT -> ANY_BIT, when they have the same type length or target bit string type is bigger
  • In case of conversion of Bool to any other bit strings, bool's value is taken as zero-th bit and padded from left by zeros.
  • ANY_INT -> ANY_INT, when target type is longer or of the same length AND if there is no loss of sign
  • REAL -> LREAL