# JavaScript Bitwise Operations
● JavaScript Bitwise Operators
https://www.w3schools.com/js/js_bitwise.asp |
● Bitwise AND
When a bitwise AND is performed on a pair of bits, it returns 1 if both bits are 1.
One bit & 4 bits example are as follows.
https://www.w3schools.com/js/js_bitwise.asp |
● Bitwise OR
When a bitwise OR is performed on a pair of bits, it returns 1 if one of the bits are 1.
One bit & 4 bits example are as follows.
https://www.w3schools.com/js/js_bitwise.asp |
● Bitwise XOR
When a bitwise XOR is performed on a pair for bits, it returns 1 if the bits are different.
https://www.w3schools.com/js/js_bitwise.asp |
● JavaScript Bitwise Operations.
JSP Bitwise operations works on 32bits signed integers.
Any number in a bitwise operation is converted into a 32 bit signed integer.
The result of a bitwise operation is converted back into a JavaSCript number.
● JavaScript Bitwise AND ( & )
Bitwise AND returns 1 only if both bits are 1.
● JavaScript Bitwise OR (|)
Bitwise OR returns 1 if one of the bits are 1.
● JavaScript Bitwise XOR ( ^ )
Bitwise XOR returns 1 if the bits are different.
● JavaScript Bitwise NOT ( ~ )
● JavaScript (Zero fill) Bitwise Left Shift (<<)
This is a zero fill left shift. One or more zero bits are pushed in from the right, and the leftmost bits fall off.
● JavaScript (Sign Preserving) Bitwise Right Shift(>>)
This is a sign preserving right shift. Copies of the leftmost bit are pushed in from the left, and the rightmost bits fall off.
No comments:
Post a Comment