by CERN

Advanced graphical user interface for particle simulation programs
◀ Previous   △ Index   Next ▶

F5.2.3} Operators

 Unary operators
 In order of decreasing precedence.
        Operator   Example    Argument type    Description
        ~~~~~~~~   ~~~~~~~    ~~~~~~~~~~~~~    ~~~~~~~~~~~
           !         !a       int              logical NOT
           ~         ~a       int              one-s complement
           !          a!      int              factorial
           -         -a       any numerical    unary minus
           +         +a       any numerical    unary plus


 Binary operators
 In order of decreasing precedence.
        Operator   Example    Argument Type    Description
        ~~~~~~~~   ~~~~~~~    ~~~~~~~~~~~~~    ~~~~~~~~~~~
          **        a**b      any numerical    exponentiation
           *         a*b      any numerical    multiplication
           /         a/b      any numerical    division
           %         a%b      int              modulo
           +         a+b      any numerical    addition
           -         a-b      any numerical    subtraction
           <         a<b      any numerical    less than
          <=        a<=b      any numerical    less than or equal to
           >         a>b      any numerical    greater than
          >=        a>=b      any numerical    greater than or equal to
          ==        a==b      any numerical    numerical equality
          !=        a!=b      any numerical    numerical inequality
           &         a&b      int              bitwise AND
           ^         a^b      int              bitwise XOR
           |         a|b      int              bitwise OR
          &&        a&&b      int              logical AND
          ||        a||b      int              logical OR
           .         a.b      string           string concatenation
          eq         a eq b   string           string equality
          ne         a ne b   string           string inequality

 The logical operators && and || short-circuit, meaning that the
 second argument is only evaluated if the truth of the entire
 expression isn't determined after evaluating the first argument.

 Ternary operator
     a ? b : c
 evaluates its first argument (which must evaluate to an integer).
 If true (nonzero), the second argument is evaluated and returned;
 otherwise, the third argument is evaluated and returned.

◀ Previous   △ Index   Next ▶