These operators are used to perform manipulation of individual bits of a number. They can be used with any of the integer types. They are used when performing update and query operations of Binary indexed tree.
- &, Bitwise AND operator: returns bit by bit AND of input values.
- |, Bitwise OR operator: returns bit by bit OR of input values.
- ^, Bitwise XOR operator: returns bit by bit XOR of input values.
- ~, Bitwise Complement Operator: This is a unary operator which returns the ones compliment representation of the input value, i.e. with all bits inversed.
Program:
public class BitwiseExample { public static void main(String[] args) { int x = 9, y = 8; // bitwise and // 1001 & 1000 = 1000 = 8 System.out.println("x & y = " + (x & y)); // bitwise XOR // 1001 ^ 1000 = 0001 = 1 System.out.println("x ^ y = " + (x ^ y)); // bitwise inclusive OR // 1001 | 1000 = 1001 = 9 System.out.println("x | y = " + (x | y)); int z = 2; // bitwise compliment // ~0010= 1101 = -3 System.out.println("~z = " + (~z)); } }Output:
x & y = 8 x ^ y = 1 x | y = 9 ~x = -3- Progamming is what actually means ?
- What is software development ?
- How we categorized software development in different manner.
C Programming
C Plus Plus
Python
Java Development
Web Designing
Javascript
Mysql
Oracle
C Plus Plus
Python
Java Development
Web Designing
Javascript
Mysql
Oracle
We cover all the programming concepts in various programming languages, this tutorials are very help full for bigener as well as Experience developer, for the ease of understanding we categorized programming in different manner likewise.