IFTHENELSE

IFTHENELSE returns its second or third argument according to the true or false value, respectively, of its first argument. It provides an equivalent for the C conditional expression (x?y:z).

Read syntax diagramSkip visual syntax diagramIFTHENELSE( x, y, z)
x
An operand that can be converted to bit. x is true if any bit in the converted bit string has the value ‘1’b.
y and z
Operands that must both be:
  • Computational (and if either is a string, it must be NONVARYING with a constant length)
  • Pointers
  • Ordinals with the same type
  • Handles to the same structure type
Given IFTHENELSE(x, y, z ), the following rules apply:
  • The first operand is evaluated, and its value determines whether the second or third operand is evaluated:
    • If the value is true, the second operand is evaluated.
    • If the value is false, the third operand is evaluated.
    The result is the value of the second or third operand.
  • If y and z are computational, the result type is the common type of y and z.
  • If either y or z is arithmetic, the result is arithmetic with the same precision as MAX(y, z) and with the common base, mode, and scale of y and z. Otherwise, the result is string with the same type as for a concatenation of y and z and with length equal to the maximum of the length of y and z.
  • If y and z are non-computational, the result type has the same type.