5.) Bitwise - Operators:-
-> It is based on the principle of performing operations bit by bit which is based on boolean algebra. It increases the processing speed and hence the efficiency of the program.
-> Bitwise operator also make possible highly efficient use of storage.
The Bitwise Operators in C/C++ Includes –
& (Bitwise AND) – Converts the value of both the operands into binary form and performs AND operation bit by bit.
| (Bitwise OR) – Converts the value of both the operands into binary form and performs OR operation bit by bit.
^ (Bitwise exclusive OR) – Converts the value of both the operands into binary form and performs EXCLUSIVE OR operation bit by bit.
~ (One’s complement operator): Converts the operand into its complementary form.
<< – Left shift
>> – Right shift
Since there are 2 variables, namely, a and b, there are 22 combinations for values a and b can take simultaneously.
AND – Both the operands should have boolean value 1 for the result to be 1.
OR – At least one operand should have boolean value 1 for the result to be 1.
XOR (EXCLUSIVE OR) – Either the first operand should have boolean value 1 or the second operand should have boolean value 1. Both cannot have the boolean value 1 simultaneously.
One Complement: iF
-> The left and right shift operators are responsible for shifting the binary values by some specific number of places.
Left shift: It specifies the value of the left operand to be shifted to the left by the number of bits specified by its right operand
Right shift: It species the value of the left operand to be shifted to the right by the number of bits specified by its right operand.
6.) Comma Operator:- This operator is used to seperate expression. [ ,]
-> It is based on the principle of performing operations bit by bit which is based on boolean algebra. It increases the processing speed and hence the efficiency of the program.
-> Bitwise operator also make possible highly efficient use of storage.
The Bitwise Operators in C/C++ Includes –
& (Bitwise AND) – Converts the value of both the operands into binary form and performs AND operation bit by bit.
| (Bitwise OR) – Converts the value of both the operands into binary form and performs OR operation bit by bit.
^ (Bitwise exclusive OR) – Converts the value of both the operands into binary form and performs EXCLUSIVE OR operation bit by bit.
~ (One’s complement operator): Converts the operand into its complementary form.
<< – Left shift
>> – Right shift
*NOTE: Bitwise operators are not applicable in the case of float and double data type in C. This operator work with integer only.
-> In order to clearly understand bitwise operators, let us see the truth table for various bitwise operations and understand how it is associated with boolean algebra.Since there are 2 variables, namely, a and b, there are 22 combinations for values a and b can take simultaneously.
AND – Both the operands should have boolean value 1 for the result to be 1.
OR – At least one operand should have boolean value 1 for the result to be 1.
XOR (EXCLUSIVE OR) – Either the first operand should have boolean value 1 or the second operand should have boolean value 1. Both cannot have the boolean value 1 simultaneously.
One Complement: iF
a
|
b
|
a&b
|
a|b
|
a^b
|
~a
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
1
|
0
|
1
|
1
|
1
|
1
|
0
|
0
|
1
|
1
|
0
|
1
|
1
|
1
|
1
|
0
|
0
|
Left shift: It specifies the value of the left operand to be shifted to the left by the number of bits specified by its right operand
Right shift: It species the value of the left operand to be shifted to the right by the number of bits specified by its right operand.
6.) Comma Operator:- This operator is used to seperate expression. [ ,]