Skip to content

Operators

CPU edited this page Jan 3, 2021 · 4 revisions

The following are the supported operators that can be used in expressions.
Be aware the type of the expression is defined by the type of the operands. string will win over everything and float will win over ints.

  • parentheses ()
    They are used to prioritize the calculations

  • sum +
    Adds two values. In case one or both of the values is a string, then it works as concatenation of the values (that are converted to strings)

  • subtraction -
    Subtract two values. Does not work on strings.

  • multiplication *
    Multiplies two values. Does not work on strings.

  • divide /
    Divides two values. Does not work on strings and fails if the second operand is zero.

  • modulo %
    Gives back the modulo of the two values, the modulo is the remainder of the division. Does not work on strings.

  • and &
    Computes the binary and of the two values. Does not work on strings and floats.

  • or |
    Computes the binary or of the two values. Does not work on strings and floats.

  • xor ^
    Computes the binary xor of the two values. Does not work on strings and floats.

  • unary negation -
    Used to change the sign of an int or a float

  • binary negation !
    transforms 0 in -1 and whatever is not 0 to 0

  • inversion ~
    Produces the one complement of the value. Does not work on strings and floats.

Priorities

TODO

Clone this wiki locally