www.pickatutorial.com Computer Tutorials
Top eBooks: C/C++ | C# | Android | Mathematics | Database | Cloud | Graphics | Networking | Oracle | Hardware | AI
Top Tutorials: C/C++ | C#.NET | PHP MySQL | Java | Java Script | jQuery | HTML | xHTML | HTML5 | VB Script| CSS
Lessons JavaScript Bitwise Operators Bookmark and Share
Tutorial Home
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Lesson 9
Lesson 10
Lesson 11
Lesson 12
Lesson 13
Lesson 14
Lesson 15
Lesson 16
Lesson 17
Lesson 18
Lesson 19
Lesson 20
Lesson 21
Lesson 22
Lesson 23
Lesson 24
Lesson 25
Lesson 26
Lesson 27
Lesson 28
Lesson 29
Lesson 30
Lesson 31
Lesson 32
Lesson 33
Lesson 34
Lesson 35
Lesson 36
Lesson 37
Lesson 38
Lesson 39
Lesson 40
Lesson 41
Lesson 42
Lesson 43
Lesson 44
Lesson 45
Lesson 46
Lesson 47
Lesson 48
Lesson 49

Working with JavaScript bitwise operators is an advanced topic and requires that you have basic knowledge of bits and bytes.

Bitwise operators in Javascipt are provided for playing with numbers at the lowest level of bits. The operands to the bitwise operators are treated as a set of 32 bits, each bit having a value 0 or 1. For instance we can write the decimal number ten as a set of 32 bits as under:

00000000000000000000000000001010

It is important to note that although bitwise operators perform their operations at the level of bits, they return standard Java Script numerical values.

The following table lists different bitwise operators available in JavaScript:

Operator Name syntax Description
Bitwise AND a & b Returns a one in each bit position for which the corresponding bits of both operands are ones.
Bitwise OR a | b Returns a one in each bit position for which the corresponding bits of either or both operands are ones.
Bitwise XOR a ^ b Returns a one in each bit position for which the corresponding bits of either but not both operands are ones.
Bitwise NOT ~ a Inverts the bits of its operand i.e. changes all zeros to ones and all ones to zeros.
Left shift a << b Shifts a in binary representation b bits to left, shifting in zeros from the right.
Sign-propagating right shift a >> b Shifts a in binary representation b bits to right, propagating the sign, discarding bits shifted off.
Zero-fill right shift a >>> b Shifts a in binary representation b bits to the right, discarding bits shifted off, and shifting in zeros from the left.

Next >>> Lesson No. 40: JavaScript Logical Operators





Home - Advertise - Contact - Disclaimer - About Us
© Since 2006 pickatutorial.com -- All Rights Reserved.