Bitwise Calculator

Perform AND, OR, and XOR bitwise operations with step-by-step explanations

Bitwise Calculator

Number of bits for calculation and result representation

Enter first decimal number

Enter second decimal number

Bitwise AND: Result is 1 only when both bits are 1

Example Bitwise Operations

AND Operation

5 & 3 = 1
101 & 011 = 001
12 & 7 = 4
1100 & 0111 = 0100

Result is 1 only when both bits are 1

OR Operation

5 | 3 = 7
101 | 011 = 111
8 | 4 = 12
1000 | 0100 = 1100

Result is 1 when at least one bit is 1

XOR Operation

5 ^ 3 = 6
101 ^ 011 = 110
9 ^ 5 = 12
1001 ^ 0101 = 1100

Result is 1 when exactly one bit is 1

Bitwise Truth Tables

AND (&)

ABA & B
000
010
100
111

OR (|)

ABA | B
000
011
101
111

XOR (^)

ABA ^ B
000
011
101
110

Number Systems

Binary (Base 2)

Uses digits 0 and 1

Example: 1101₂ = 13₁₀

Decimal (Base 10)

Uses digits 0-9

Example: 87₁₀ = 1010111₂

Octal (Base 8)

Uses digits 0-7

Example: 127₈ = 87₁₀

Bitwise Tips

AND is useful for masking bits

OR is useful for setting bits

XOR is useful for toggling bits

XOR with itself equals zero

Understanding Bitwise Operations

What are Bits?

A bit is the smallest unit of information in computing, representing a logical state with two possible values: 0 or 1. Bits are combined to form larger data structures, with 8 bits making one byte. Understanding bitwise operations is fundamental in computer science.

Applications:

  • • Data compression and encryption
  • • Network programming and IP masking
  • • Graphics and image processing
  • • Embedded systems programming
  • • Database indexing and optimization

Bitwise vs Logical Operations

Bitwise Operations

Operate on individual bits of numbers. Each bit position is processed independently according to the truth table of the operation.

Number Representation

Numbers can be represented in different bases (binary, decimal, octal, hexadecimal). Our calculator supports binary, decimal, and octal inputs for flexibility.

Two's Complement

Negative numbers are represented using two's complement notation, which allows consistent bitwise operations across positive and negative integers.