Bitwise Calculator – Free Online Bitwise Operation Tool
Perform bitwise operations like AND, OR, XOR, NOT, left shift, and right shift instantly. Free online bitwise calculator for programming and digital logic.
Perform bitwise operations AND, OR, XOR, NOT, shift instantly. Free online bitwise calculator for programming.
What is Bitwise Calculator?
Bitwise Calculator is a free online tool that performs bitwise operations on binary numbers including AND, OR, XOR, NOT, left shift, and right shift. Bitwise operations are fundamental in low-level programming, embedded systems, digital electronics, cryptography, and network programming.
Bitwise Operations Explained
AND Operation: Returns 1 only when both bits are 1. Example: 1010 AND 1100 = 1000. Used for masking and clearing bits.
OR Operation: Returns 1 when at least one bit is 1. Example: 1010 OR 1100 = 1110. Used for setting bits.
XOR Operation: Returns 1 when bits are different. Example: 1010 XOR 1100 = 0110. Used for toggling bits and encryption.
NOT Operation: Inverts all bits. Example: NOT 1010 = 0101. Used for complement operations.
Left Shift (<<): Moves bits left, fills with zeros. Example: 0010 << 1 = 0100 (multiplies by 2).
Right Shift (>>): Moves bits right, preserves sign bit. Example: 0100 >> 1 = 0010 (divides by 2).
Zero-fill Right Shift (>>>): Shifts in zeros regardless of sign.
Common Use Cases
IP Subnetting: Bitwise AND is used to calculate network addresses from IP and subnet mask. Example: 192.168.1.100 AND 255.255.255.0 = 192.168.1.0.
Flag Management: Use OR to set flags, AND to check flags, XOR to toggle flags.
Color Manipulation: Extract RGB components using bitwise AND with masks.
Cryptography: XOR is fundamental in many encryption algorithms like RC4.
Error Detection: XOR is used in checksums and parity calculations.
Bitwise Truth Tables
AND: 0 AND 0 = 0, 0 AND 1 = 0, 1 AND 0 = 0, 1 AND 1 = 1.
OR: 0 OR 0 = 0, 0 OR 1 = 1, 1 OR 0 = 1, 1 OR 1 = 1.
XOR: 0 XOR 0 = 0, 0 XOR 1 = 1, 1 XOR 0 = 1, 1 XOR 1 = 0.
NOT: NOT 0 = 1, NOT 1 = 0.
Programming Examples
JavaScript: let result = a & b; (AND), let result = a | b; (OR), let result = a ^ b; (XOR), let result = ~a; (NOT), let result = a << b; (Left shift), let result = a >> b; (Right shift).
Python: result = a & b (AND), result = a | b (OR), result = a ^ b (XOR), result = ~a (NOT), result = a << b (Left shift), result = a >> b (Right shift).
C/C++: Same operators as JavaScript and Python.
Java: Also supports >>> for unsigned right shift.
Bitwise Calculation Examples
Example 1: 12 (1100) AND 10 (1010) = 8 (1000).
Example 2: 12 (1100) OR 10 (1010) = 14 (1110).
Example 3: 12 (1100) XOR 10 (1010) = 6 (0110).
Example 4: NOT 5 (0101) = 10 (1010) for 4-bit, or -6 for 32-bit signed.
Example 5: 3 (0011) << 2 = 12 (1100).
Example 6: 12 (1100) >> 2 = 3 (0011).
Bit Masks and Flags
Common bit masks: Bit 0 (1), Bit 1 (2), Bit 2 (4), Bit 3 (8), Bit 4 (16), Bit 5 (32), Bit 6 (64), Bit 7 (128).
Setting a flag: flags = flags | MASK.
Clearing a flag: flags = flags & ~MASK.
Toggling a flag: flags = flags ^ MASK.
Checking a flag: if (flags & MASK) then flag is set.
Conclusion
Bitwise Calculator is essential for programmers, embedded systems engineers, and computer science students. It provides fast, accurate bitwise operations for debugging, learning, and development. Use it for IP subnetting, flag management, cryptography, and low-level programming tasks.
Frequently Asked Questions
Everything you need to know about this tool