MATHEMATICS
Number operations
Operators Priority Function
------------------------------------------------
! 0 logical not
~ 0 bitwise not
* 1 integer multiply
** 1 integer power
/ 1 integer divide
// 1 integer sqrt // 2 or cbrt // 3
% 1 integer modulo
d 1 integer random dice roll
+ 2 integer addition
- 2 integer subtraction
<< 3 bitwise shift
>> 3 bitwise shift
> 4 logical greater than
>= 4 logical greater than or equal
< 4 logical less than
<= 4 logical less than or equal
== 5 logical equal
!= 5 logical not equal
& 6 bitwise and
^ 7 bitwise xor
| 8 bitwise or
&& 9 logical and
^^ 10 logical xor
|| 11 logical or
Operator priority can be ignored by using parentheses, for example
(1 + 1) * 2 equals 4, while 1 + 1 * 2 equals 3.
String operations
Operators Priority Function
------------------------------------------------
> 4 alphabetical greater than
>= 4 alphabetical greater than or equal
< 4 alphabetical less than
<= 4 alphabetical less than or equal
== 5 alphabetical equal using regex
!= 5 alphabetical not equal using regex
=== 5 alphabetical equal
!== 5 alphabetical not equal
Strings must be encased in double quotes or braces. The > >= < <=
operators perform basic string comparisons. The == != operators perform
regular expressions, with the argument on the left being the string,
and the argument on the right being the regex. For example
{bla} == {%*a} would evaluate as 1.
Related: math and regexp.
|