filmov
tv
2.3 Bitwise Operators In Java | Shift Operators In Java | Data Operators In Java (Part 2)

Показать описание
Data Operators In Java | Arithmetic And Unary Operators (Part - 1)
follow me on:
Bitwise Operators In Java | Shift Operators In Java | Data Operators In Java
Bitwise operator
1) AND bitwise operator
2) OR bitwise operator
3) XOR bitwise operator
4) Complement operator
AND bitwise operator:
------------------------------------
This operator is a binary operator, denoted by ‘&’. It returns bit by bit AND of input values, i.e, if both bits are 1, it gives 1, else it gives 0.
OR bitwise operator:
------------------------------------
This operator is a binary operator, denoted by ‘|’. It returns bit by bit OR of input values, i.e, if either of the bits is 1, it gives 1, else it gives 0.
XOR bitwise operator:
_______________________
This operator is a binary operator, denoted by ‘^’. It returns bit by bit XOR of input values, i.e, if corresponding bits are different, it gives 1, else it gives 0.
Complement bitwise operator:
--------------------------------------------------
This operator is a unary operator, denoted by ‘~’. It returns the one’s complement representation of the input value, i.e, with all bits inverted, means it makes every 0 to 1, and every 1 to 0.
Shift Operators
1) Left shift operator
2) Right shift operator
Left shift operator
-------------------------------
Shifts the bits of the number to the left and fills 0 on voids left as a result. Similar effect as of multiplying the number with some power of two.
Right shift operator
--------------------------------
Shifts the bits of the number to the right and fills 0 on voids left as a result. The leftmost bit depends on the sign of the initial number. Similar effect as of dividing the number with some power of two.
follow me on:
Bitwise Operators In Java | Shift Operators In Java | Data Operators In Java
Bitwise operator
1) AND bitwise operator
2) OR bitwise operator
3) XOR bitwise operator
4) Complement operator
AND bitwise operator:
------------------------------------
This operator is a binary operator, denoted by ‘&’. It returns bit by bit AND of input values, i.e, if both bits are 1, it gives 1, else it gives 0.
OR bitwise operator:
------------------------------------
This operator is a binary operator, denoted by ‘|’. It returns bit by bit OR of input values, i.e, if either of the bits is 1, it gives 1, else it gives 0.
XOR bitwise operator:
_______________________
This operator is a binary operator, denoted by ‘^’. It returns bit by bit XOR of input values, i.e, if corresponding bits are different, it gives 1, else it gives 0.
Complement bitwise operator:
--------------------------------------------------
This operator is a unary operator, denoted by ‘~’. It returns the one’s complement representation of the input value, i.e, with all bits inverted, means it makes every 0 to 1, and every 1 to 0.
Shift Operators
1) Left shift operator
2) Right shift operator
Left shift operator
-------------------------------
Shifts the bits of the number to the left and fills 0 on voids left as a result. Similar effect as of multiplying the number with some power of two.
Right shift operator
--------------------------------
Shifts the bits of the number to the right and fills 0 on voids left as a result. The leftmost bit depends on the sign of the initial number. Similar effect as of dividing the number with some power of two.