Enter binary values and calculate AND, OR, XOR, and NOT while seeing every bit position in the visual grid.
Number A
Binary
Dec46Bin00101110Hex0x2E
Invalid input.
Value exceeds selected bit width.
Number BBinary
Dec74Bin01001010Hex0x4A
Invalid input.
Value exceeds selected bit width.
Results Summary
AND (&)
Dec0
Hex0x00
Bin00000000
OR (|)
Dec0
Hex0x00
Bin00000000
XOR (^)
Dec0
Hex0x00
Bin00000000
NOT (~A)
Dec0
Hex0x00
Bin00000000
Bit-by-Bit Visualization
1 Active bit0 Diff bit0 Included zero0 Leading zero
Interactive Truth Table Matrix
Click a row to load values into A and B, or inspect how each gate behaves.
Input A
Input B
AND
OR
XOR
NOT A
0
0
0
0
0
1
0
1
0
1
1
1
1
0
0
1
1
0
1
1
1
1
0
0
Click a truth table row to test those values.
Copied.
How the Binary Bitwise Calculator Works
A binary bitwise calculator works directly with 0s and 1s. It aligns the input bit strings, applies the selected bitwise operation, and returns the result in binary, decimal, and hexadecimal formats.
01
Binary Input
Use bit strings such as 101110, 1001010, 11110000, or 00001111.
&|^
Operator Support
Run AND, OR, XOR, and NOT calculations from the same binary-focused interface.
col
Column Alignment
The calculator pads shorter values so matching bit positions line up correctly.
0x
Format Conversion
Read the same binary result as decimal or hexadecimal without changing tools.
Binary Bitwise Calculation Steps
Use these steps to calculate bitwise operations from binary input.
Enter Binary Values
Select Binary for each input.
Type only 0s and 1s.
Choose a bit width when fixed-width output matters.
Apply the Operator
Use AND to keep shared 1 bits.
Use OR to combine active bits.
Use XOR to mark different bits or NOT to flip A.
Read the Output
Check the binary result first.
Use decimal for integer value checks.
Use hex for compact byte or mask review.
Binary Bitwise Examples
Binary examples show how each operator changes the bit pattern.
Input
Operation
Result
Use
101110 & 1001010
AND
001010
Shared active bits
101110 | 1001010
OR
1101110
Combined active bits
101110 ^ 1001010
XOR
1100100
Different bit positions
~00101110
8-bit NOT
11010001
Binary complement
Why Use This Binary Bitwise Calculator?
Use this binary calculator when you want to inspect raw bit strings, masks, flags, and packed integer values.
01
Binary-Only Input
Both fields accept 0s and 1s, so you can paste bit strings straight from a datasheet or debugger.
&|^
All Operators at Once
Compare AND, OR, XOR, and NOT results for the same pair of inputs.
_
Automatic Alignment
Shorter inputs are padded with leading zeros so every column lines up.
64
Up to 64 Bits
Inspect byte, word, double-word, and 64-bit patterns.
Practical Uses for Binary Bitwise Math
Binary bitwise calculations are useful for masks, permissions, protocol fields, embedded values, and computer science practice.
reg
Register Maps
Decode hardware register values bit by bit from a microcontroller datasheet.
#
Popcount Checks
Count set bits and confirm results from bit_count or __builtin_popcount.
CS
Coursework
Check digital logic and computer architecture homework step by step.
pkt
Protocol Headers
Read individual flag bits in TCP, USB, or CAN frames.
Reading Binary Numbers
Binary is base 2. Each digit (a bit) is worth twice the digit to its right, starting from 1 at the far right:
Bit position
7
6
5
4
3
2
1
0
Place value
128
64
32
16
8
4
2
1
00101110
0
0
1
0
1
1
1
0
To convert binary to decimal, add the place values of every 1: 32 + 8 + 4 + 2 = 46. To go the other way, repeatedly divide by 2 and read the remainders from bottom to top, or subtract the largest place value that fits until you reach zero.
Bit 0 is called the least significant bit (LSB) because it changes the value the least. The leftmost bit of a fixed-width number is the most significant bit (MSB). In signed two’s complement numbers, the MSB is the sign bit.
How This Binary Calculator Aligns Bits
Bitwise operators compare bits that sit in the same position, so both operands must be aligned on the right. When you enter 101110 and 1001010, the calculator pads the shorter value with leading zeros:
A = 0101110B = 1001010
Leading zeros never change a value, but they matter for display and for NOT. The bit grid above marks leading zeros differently from zeros inside the number so you can tell them apart. Choose a fixed width (8, 16, 32, or 64 bits) to see the result exactly as a register or integer type would store it.
All Four Operations on the Same Inputs
With A = 00101110 (46) and B = 01001010 (74):
Operation
Rule
Result (binary)
Decimal
Hex
A AND B
1 if both are 1
00001010
10
0x0A
A OR B
1 if either is 1
01101110
110
0x6E
A XOR B
1 if they differ
01100100
100
0x64
NOT A (8-bit)
flip every bit
11010001
209
0xD1
Comparing the rows column by column is the fastest way to build intuition. AND keeps the overlap, OR keeps the union, XOR keeps the difference, and NOT keeps the opposite.
Writing Binary Literals in Code
Most languages accept binary literals with a 0b prefix, which makes masks easier to read than decimal:
mask = 0b0000_1111 # underscores are allowed for readabilityprint(0b00101110 & mask) # 14print(format(46, "08b")) # '00101110'print(int("00101110", 2)) # 46
C added 0b literals in C23, and C++ has had them since C++14 (with ' as a digit separator, for example 0b0010'1110). Older C compilers often accept them as an extension, but hex is the portable choice there.
Grouping Bits Into Nibbles and Bytes
Long binary strings are hard to read, so engineers group them:
A nibble is 4 bits and maps to exactly one hex digit.
A byte is 8 bits, two nibbles, or two hex digits.
A word depends on the platform. It is commonly 16, 32, or 64 bits.
Writing 0010 1110 instead of 00101110 makes it obvious that the value is 0x2E. When you work with masks, group by the field boundaries instead. For example, an 8-bit status register might be split into [3-bit mode][1-bit enable][4-bit count].
Counting Set Bits and Other Binary Checks
A few binary questions come up constantly:
Population count (popcount): the number of 1 bits. 46 = 00101110 has four. Python has int.bit_count() (3.10+), C++ has std::popcount, and GCC and Clang provide __builtin_popcount.
Bit length: the position of the highest 1 plus one. 46 needs 6 bits. Python’s int.bit_length() returns this.
Lowest set bit:x & -x isolates it. For 46 the result is 2 (00000010).
Clear the lowest set bit:x & (x - 1). Applying it in a loop until zero is a classic popcount method.
Common Binary Mistakes
Reading bits in the wrong direction. Bit 0 is on the right. Position numbers increase to the left.
Dropping leading zeros before NOT.NOT 101 is 010 at 3 bits but 11111010 at 8 bits.
Confusing a binary string with a decimal number. In code, 101 is one hundred and one. Use 0b101 or int("101", 2).
Signed vs unsigned reading.11010001 is 209 unsigned but −47 as a signed 8-bit value.
Find answers to common questions about bitwise operations and this online tool.
How do I convert binary to decimal?
Add the place values of every 1 bit. Place values double from right to left: 1, 2, 4, 8, 16, 32, 64, 128. For 00101110 that is 32 + 8 + 4 + 2 = 46.
Why does the calculator add leading zeros?
Bitwise operators compare bits in the same position, so both inputs are right-aligned and padded to the same length. Leading zeros never change the value but matter for NOT and for fixed-width display.
What is the difference between a bit, a nibble, and a byte?
A bit is one binary digit. A nibble is 4 bits and equals one hex digit. A byte is 8 bits, or two hex digits.
How do I write binary numbers in code?
Python, JavaScript, Java, C++14 and later, and C23 accept a 0b prefix, for example 0b00101110. Many also allow separators such as 0b0010_1110.
What does LSB and MSB mean?
LSB is the least significant bit, the rightmost bit with value 1. MSB is the most significant bit, the leftmost bit of a fixed-width value, which is also the sign bit in signed numbers.
How do I count the number of 1 bits?
Use a population count function such as int.bit_count() in Python 3.10+, std::popcount in C++20, or __builtin_popcount in GCC and Clang. 46 (00101110) has four set bits.