Velo supports arithmetic, comparison, logical, and bitwise operators with some unique design choices. |
|
Standard arithmetic operators work as expected. |
int a = 10;
int b = 3;
int sum = a + b; # 13
int diff = a - b; # 7
int prod = a * b; # 30
int quot = a / b; # 3
int rem = a % b; # 1
|
Unary minus is supported for negation. |
int x = -10;
int y = -x; # 10
int z = 5 + -3; # 2
int w = -(-2); # 2
|
Comparison operators return bool values. |
bool eq = a == b; # false
bool ne = a != b; # true
bool lt = a < b; # false
bool gt = a > b; # true
bool le = a <= b; # false
bool ge = a >= b; # true
|
Velo uses & for AND, | for OR, and ^ for XOR. There are no && or || operators — both operands are always evaluated. |
bool a = true;
bool b = false;
bool and = a & b; # false
bool or = a | b; # true
bool xor = a ^ b; # true
|
There is no unary ! operator. Use == false for negation. |
bool value = true;
if (value == false) {
# negation
};
|
Bitwise shift operators are available for integers. |
int shl = 5 << 1; # left shift
int shr = 5 >> 1; # right shift
|