+ 6
Bitwise
what does bitwise operators mean
2 Answers
+ 20
a bitwise operation operates on one or more bit patterns or binary numerals at the level of their individual bits.It is fast simple action directly supported by the processor and is used to manipulate values for comparison and calculations.
For example in JS:
5 &13 => 0101 & 1101 = 0101; in 10 base output will be 5 ("0101")
Bitwise operators in JS:
& - bitwise AND
| - bitwise OR
^ - bitwise XOR
~ - bitwise NOT
<< - left shift
>> - sign-propagation right shift
>>> - zero-fill right shift
There are many hacks in JS (don't use it!!!) for represent the whole part of number, for example, ~~4.567 will output 4, also you can use XOR operator with zero, for example, 4.567 ^ 0 will output the same result 4.
And so on...
+ 2
Bitwise operator perform the operations....with the values of the operand considering its corresponding BITS...likely bitwise...
And its operators are above mentioned .......
for eg....
a=3 and b= 2....in bits
a=0000 0000 0000 0011
b=0000 0000 0000 0010. in bits...
and on a&b (a and b)
the output will be 2
since the 'and' operator returns 1 if both the inputs are non-zero....
so a & b=0000 0000 0000 0010....which is equal to 2