Main Index : Reference :
These are the available operators in C.O.F.F.E.E.:
| Symbol | Explanation | Example | |
| Math | * |
Multiply | 2 * 3 = 6 |
/ |
Divide | 6 / 3 = 2 |
|
% |
Remainder | 5 % 16 = 1 |
|
+ |
Add | 3 + 2 = 5 |
|
- |
Subtract | 3 - 2 = 1 |
|
- |
Unary minus | -5 * 3 = -15 |
|
| Assignment | = |
Assignment | var a = 3 |
+=, etc. |
Compound assignment (the left-hand side is used as the first operand) |
i += 1 means i = i + 1 |
|
| Relational | == |
Equal (TRUE if the operandshave the same value) |
3 == 3 |
!= |
Not equal (TRUE if theoperands differ) |
6 != 8 |
|
< |
Less than (TRUE if the firstoperand's value is less than the second's) |
5 < 10 |
|
<= |
Less than or equal to (TRUE ifthe first operand's value is less than or equal to the second's) |
4 <= 5 |
|
< |
Greater than (TRUE if the firstoperand's value is greater than the second's) |
5 > 1 |
|
<= |
Greater than or equal to (TRUE ifthe first operand's value is greater than or equal to the second's) |
4 <= 3 |
|
| Logical | ! |
Logical NOT (TRUE if theoperand is FALSE) |
if (!ok) return |
&& |
Logical AND (TRUE if bothoperands are TRUE) |
2 < 3 && 4 == 4 |
|
|| |
Logical OR (TRUE if eitheroperand is TRUE) |
4 < 5 || 4 >= 5 |
|
| Increment | ++ |
Post-increment (increases the operand's value but returns the original value) |
i++ |
++ |
Pre-increment (increases the operand's value and returns the new value) |
++i |
|
| Decrement | -- |
Post-decrement (decreases the operand's value but returns the original value) |
i-- |
-- |
Pre-decrement (decreases the operand's value and returns the new value) |
--i |
|
| Bitwise | ~ |
Bitwise NOT | ~0x2B = 0xD4 |
& |
Bitwise AND | 0x2B & 0xF1 = 0x21 |
|
| |
Bitwise OR | 0x2B | 0xF1 = 0xFB |
|
^ |
Bitwise XOR | 0x2B ^ 0xF1 = 0xDA |
|
<< |
Bitwise left shift | 0x2B << 2 = 0xAC |
|
>> |
Bitwise right shift | 0x2B >> 2 = 0x0A |
|
| Other | ? : |
Conditional (returns the middle operand's value if the first operand is TRUE, otherwise returns theright operand's value) |
1 ? "yes" : "no" |
() |
Parentheses | (5 + 3) * 7 = 56 |
|
[] |
Array-element | a[0] |
|
-> |
Member access | obj->Move() |
|
. |
Vector access | v.x |
|
& |
Reference (passes a variable by reference to a function, so that the function accesses the variable directly) |
function(&x) |
| Symbol | Meaning | |
| Highest Precedence | () |
Parentheses |
++ |
Post-increment | |
-- |
Post-decrement | |
[] |
Array-element | |
-> |
Member access | |
. |
Vector access | |
++ |
Pre-increment | |
-- |
Pre-decrement | |
! |
Logical NOT | |
~ |
Bitwise NOT | |
- |
Unary minus | |
* |
Multiply | |
/ |
Divide | |
% |
Remainder | |
+ |
Add | |
- |
Subtract | |
<< |
Bitwise left shift | |
>> |
Bitwise right shift | |
< |
Less than | |
<= |
Less than or equal to | |
< |
Greater than | |
<= |
Greater than or equal to | |
== |
Equal | |
!= |
Not equal | |
& |
Bitwise AND | |
^ |
Bitwise XOR | |
| |
Bitwise OR | |
&& |
Logical AND | |
|| |
Logical OR | |
? : |
Conditional | |
= |
Assignment | |
| Lowest Precedence | +=, etc. |
Compound assignment |