Skip to content
🛠️ToolsShed

Bitwise Calculator

Perform bitwise operations with binary visualization.

Result

10

Binary representation (8-bit)
A00101010
B00011011
=00001010

About this tool

A bitwise calculator lets you perform logical operations directly on binary representations of numbers. These operations—AND, OR, XOR, NOT, left shift, and right shift—form the foundation of low-level programming, hardware design, and data compression. Understanding how bits combine is essential for anyone working with embedded systems, cryptography, or network protocols.

To use this tool, enter numbers in decimal, binary, or hexadecimal format and select an operation. The calculator instantly displays the result alongside a visual binary representation, making it easy to see how each bit changes. Common use cases include debugging bit-flag logic in your code, understanding how permissions are encoded in system calls, and learning how bitwise tricks can optimize algorithms.

This calculator is invaluable for computer science students, systems programmers, and anyone reverse-engineering data formats. It removes the mental burden of manual binary conversion, letting you focus on understanding the logic behind the operation itself.

Frequently Asked Questions

Code Implementation

# Bitwise operations in Python

a = 0b1100  # 12
b = 0b1010  # 10

# Basic bitwise operations
print(a & b)   # AND: 8  (0b1000)
print(a | b)   # OR:  14 (0b1110)
print(a ^ b)   # XOR: 6  (0b0110)
print(~a)      # NOT: -13 (inverts all bits)

# Bit shifts
print(a << 2)  # Left shift: 48 (0b110000)
print(a >> 1)  # Right shift: 6  (0b110)

# Practical: bitmask for permissions
READ    = 0b001  # 1
WRITE   = 0b010  # 2
EXECUTE = 0b100  # 4

perms = READ | WRITE  # 3
print(perms & READ)    # 1 — has read permission
print(perms & EXECUTE) # 0 — no execute permission

# Set/clear/toggle a bit
n = 0b10110
bit = 2
n |= (1 << bit)   # set bit 2
n &= ~(1 << bit)  # clear bit 2
n ^= (1 << bit)   # toggle bit 2

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.