+ |
Used to indicate a positive value. Examples: +10 +32 +1.25 |
||
- |
Used to indicate a negative value. Examples: -10 -32 -1.25 |
+ |
Addition - Integer and floating point |
||
- |
Subtraction - Integer and floating point |
||
* |
Multiplication - Integer and floating point |
||
/ |
Division - Integer (no fractions) and floating point |
||
% |
Mod division (integers only. Gives remainder after a division) |
||
= |
Assignment |
== |
Is equal to - Determine if two values are equal in conditional statements.
Use with caution if the values are float or double. |
||
!= |
Not equal - Determine if two values are not equal in conditional statements.
Use with caution if the values are float or double. |
||
< |
Less than - Determine if one value is less than another value in conditional statements.
Use with caution if the values are float or double. |
||
> |
Greater than - Determine if one value is greater than another value in conditional statements.
Use with caution if the values are float or double. |
||
<= |
Less than or equal - Determine if one value is less than or equal to
another value in conditional statements.
Use with caution if the values are float or double. |
||
>= |
Greater than or equal - Determine if one value is greater than or equal to
another value in conditional statements.
Use with caution if the values are float or double. |
&& |
Logical AND - Perform a logical AND operation on two conditionals. If either
conditional is false the entire statement is false. |
||
|| |
Logical OR - Perform a logical OR operation on two conditionals. If either
conditional is true the entire statement is true. |
||
! |
Logical NOT - Perform a logical NOT operation on a single conditional. This
inverts the result of the conditional. If the conditional is true the logical NOT
operator makes it false. |
+= |
Add and assign - The statement X = X + 1; can be written as
X += 1; This sets X to the value of X plus 1. |
||
-= |
Subtract and assign - The statement X = X - 2; can be written as
X -= 2; This sets X to the value of X minus 2. |
||
*= |
Multiply and assign - The statement X = X * 4; can be written as
X *= 4; This sets X to the value of X time 4. |
||
/= |
Divide and assign - The statement X = X / 2; can be written as
X /= 2; This sets X to the value of X divided by 2. |
||
%= |
Mod divide and assign - The statement X = X % 2; can be written as
X %= 2; This sets X to the remainder of X divided by 2. |
++ |
Pre-increment (++X) - Increment the variable value then use it. |
||
++ |
Post-increment (X++) - Use the current value of the variable then
increment it. |
||
-- |
Pre-decrement (--X) - Decrement the variable value then use it. |
||
-- |
Post-increment (X--) - Use the current value of the variable then
decrement it. |
<< |
Left bit shift - Shift all bits in the variable to the left. This has the
effect of multiplying the value by 2. |
||
>> |
Right bit shift - Shift all bits in the variable to the right. This has the
effect of dividing the value by 2. |
||
& |
Bit-wise AND - Perform a bit-wise AND on the corresponding bits in two
integer variables or values. |
||
| |
Bit-wise OR - Perform a bit-wise OR on the corresponding bits in two
integer variables or values. |
||
^ |
Bit-wise exclusive OR - Perform a bit-wise XOR (Exclusive OR) on the corresponding
bits in two integer variables or values. |
||
~ |
Bit inversion - Invert all bits in an integer variable. All 1's become
zero and all 0's become ones. |
<<= |
Left shift and assign |
||
>>= |
Right shift and assign |
||
&= |
AND and assign |
||
|= |
OR and assign |
||
^= | XOR and assign |
X <<<=2; |
Set X equal to X bit shifted left by 2 places. |
||
X >>=4; |
Set X equal to X bit shifted right by 4 places |
||
X &=18; |
Set X equal to X bit ANDed with 18 |
||
X &=0x12; |
Set X equal to X bit ANDed with hex 12 (decimal 18) |
||
X |=7; | Set X equal to X bit Ored with 7 | ||
X ^=2; | Set X equal to X bit XORed with 2 |