Operator | NAME | DESCRIPTION | Example Output |
---|---|---|---|
+ | Addition | Adds values on either side of the operator | a + b = 70 |
- | Subtraction | Subtracts right hand operand from left hand operand | a - b = 10 |
* | Multiplication | Multiplies values on either side of the operator | a * b = 1200 |
/ | Division | Divides left hand operand by right hand operand | a / b = 1.3 |
% | Modulus | Divides but returns remainder | a % b = 0 |
++ | Increment | Increases the value of operand by 1 | b++ gives 31 |
-- | Decrement | Decreases the value of operand by 1 | a-- gives 39 |
Operator | NAME | DESCRIPTION | Example Output |
---|---|---|---|
== | Double Equals To | Checks if the values of two operands are equal or not. | (a == b) is not true |
!= | Not Equal To | Checks if the values of two operands are equal or not. | (a != b) is true |
> | Greater Than | Checks left value is greater than the value of right operand. | (a > b) is not true |
< | Less Than | Checks left value is less than the value of right operand. | (a < b) is true |
>= | Greater Than Equal To | Checks left value is greater than or equal to the right value. | (a >= b) is not true |
<= | Less Than Equal To | Checks left value is less than or equal to the right value. | (a <= b) is true |
Operator | NAME | DESCRIPTION | Example Output |
---|---|---|---|
&& | Logical AND | If both the operands are non-zero, then the condition becomes true. | (A && B) is false. |
|| | Logical OR | If any of the two operands are non-zero, then the condition becomes true. | (A || B) is true |
! | Logical NOT | Use to reverses the logical state of its operand. If a condition is true then Logical NOT operator will make false. | !(A && B) is true. |
Operator | NAME | DESCRIPTION | Example Output |
---|---|---|---|
& | Binary AND Operator copies a bit to the result if it exists in both operands. | (A & B) will give 12 which is 0000 1100 | |
| | Binary OR Operator copies a bit if it exists in either operand. | (A | B) will give 61 which is 0011 1101 | |
^ | Binary XOR Operator copies the bit if it is set in one operand but not both. | (A ^ B) will give 49 which is 0011 0001 | |
~ | Binary Ones Complement Operator is unary and has the effect of 'flipping' bits. | (~A ) will give -60 which is 1100 0011 | |
<< | Binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand. | A << 2 will give 240 which is 1111 0000 | |
%= | Modulus and Assignment | It takes modulus using two operands and assign the result to left operand | C %= A is equivalent to C = C % A |
<<= | Left shift and Assignment operator | C <<= 2 is same as C = C << 2 | |
>>= | Right shift AND assignment operator | C >>= 2 is same as C = C >> 2 | |
&= | Bitwise AND assignment operator | C &= 2 is same as C = C & 2 | |
^= | bitwise exclusive OR and assignment operator | C ^= 2 is same as C = C ^ 2 | |
|= | bitwise inclusive OR and assignment operator | C |= 2 is same as C = C | 2 |
| Copyright ©2016 | All Rights Reserved |
| Design by Uves Khan |