+ 1
What is bitwise operator ?
2 odpowiedzi
+ 4
in every programming language, each variable can be broken down to individual bits which represent its value (that is that every computer store any type of information, just an endless sea of zeroes and ones)
for instance int value in C language takes 4 bytes.
each byte is broken down to i bits
each bit can be either 0 or 1
so 4 times 8 give us 32 bits in total for an int type variable
now, what is bitwise operator?
there is more than one(AND, OR, XOR, SHIFTING), but all of them work directly on the bit level, meaning, they allow for direct manipulation of the bits which represent a value.
for instance, look at this declaration:
int x = 1;
the int value x holds a value of 1, but behind the scenes, it will be represented as 31 bits (from left to right) which are zero, and the last bit as 1
0000 0000 0000 0000 0000 0000 0000 0001
so different bitwise operators allow to directly manipulate the actual bits of a variable
for more, refer to http://www.cprogramming.com/tutorial/bitwise_operators.html
+ 1
Bitwise operators are AND, OR, XOR, and NOT. They are either True or False (1 or 0), and are used in if statements to make decisions.