Operators

Unary Operators

OperatorOperationExample
-Negates a value---5 = -5
!Inverts a value!false = true

Arithmetic Operators

OperatorOperationExample
+Adds two values1+2 = 3
-Substracts two values3-2 = 1
*Multipies two values2*3 = 6
/Divides two values4/2 = 2
%Remainder of a division5%3 = 2

Logic / Bitwise Operators

OperatorOperationExample
&&AND Logic gatetrue && false = false
\|\|OR Logic gatetrue \|\| false = true
^XOR Logic gatetrue ^ true = false
<<Shift n times to the left1<<2 = 5
>>Shift n times to the right5>>2 = 1
==Compares if two values are equal5==5.0 = true
!=Compares if two values are different5!=5 = false
>=Compares if first value is greater or equal than the second5>=6 = false
<=Compares if first value is lower or equal than the second5<=6 = true
>Compares if first value is greater than the second5>5 = false
<Compares if first value is lower or equal than the second5<5 = false

Optimizations

All operators are essentially functions, and they are all also constant, that when the values they entail are constant (known at compile-time), their results will be inlined as it happens with functions.

Input Moon Script Optimization
return 10 + 5
return 15
let num = 15
let comparasion = num > 10
return comparasion
return true