Bitwise Calculator
Calculate AND, OR, XOR, NOT, left shift, and right shift with binary, decimal, or hexadecimal input. This online math tool aligns each bit, shows the operation step by step, and returns the result in all three number systems.
46 Hex0x2E 74 Hex0x4A Results Summary
Bit-by-Bit Visualization
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 |
What Are Bitwise Operations?
Bitwise operations process the binary digits of an integer one position at a time. The Bitwise Calculator tool lines up Number A and Number B, applies one rule to every bit pair, and builds the output pattern. Software developers, computer science students, and engineers use bit-level analysis in systems programming, graphics, networking, cryptography, and performance optimization.
One-Bit Logic Lab
AND returns 1 only when A and B are both 1.
Bitwise AND (&)
Bitwise AND returns 1 only when both aligned input bits are 1. The Bitwise AND operation keeps shared active bits, which makes AND useful for masking and permission checks. For example, 1100 & 1010 = 1000.
Bitwise OR (|)
Bitwise OR returns 1 when either aligned input bit is 1. The Bitwise OR operator combines flags and sets selected bits without clearing active bits. For example, 1100 | 1010 = 1110.
Bitwise XOR (Exclusive OR)
Bitwise XOR returns 1 when the aligned input bits are different. A Bitwise XOR Calculation marks changed positions and supports toggles, parity checks, checksums, and error detection. For example, 1100 ^ 1010 = 0110.
Bitwise NOT (~)
Bitwise NOT flips every included bit: 1 becomes 0 and 0 becomes 1. The selected bit width controls the number of inverted positions. For example, 8-bit ~00001100 = 11110011.
Bitwise Left Shift (<<)
A left Bit Shift moves every bit left by the shift count and fills new right-side positions with zeros. An unsigned value shifted left by n positions is multiplied by 2^n when no significant bit overflows.
Bitwise Right Shift (>>)
Bitwise right shift moves every bit right and discards low bits that pass the right edge. A logical right shift fills new left-side positions with zeros and divides an unsigned integer by 2^n, rounded down.
What Is a Bit? Understanding Binary, Decimal, and Hexadecimal
A bit is the smallest unit of digital information and stores one of two values: 0 or 1. A group of 8 bits forms a byte with 256 possible patterns. Number systems write the same integer with different bases, while the underlying bit pattern stays unchanged.
Number System Converter
Binary Numbers
Binary is a base-2 number system that uses 0 and 1. Each position represents a power of 2. The binary value 1010 equals 1x2^3 + 0x2^2 + 1x2^1 + 0x2^0, or decimal 10. Binary input exposes the exact bits used by each operation.
Decimal Numbers
Decimal is the base-10 number system used for everyday integer values. Each position represents a power of 10. The calculator converts decimal input to binary before applying bitwise logic, so decimal 10 and binary 1010 produce the same bitwise result.
Hexadecimal Numbers
Hexadecimal is a base-16 number system that uses 0-9 and A-F. One hexadecimal digit represents four bits, called a nibble. Hex 0x0A, decimal 10, and binary 1010 represent the same value. Octal uses base 8, but this tool accepts binary, decimal, and hexadecimal input.
| Decimal | Binary (8-bit) | Hexadecimal | Bit pattern use |
|---|---|---|---|
0 | 00000000 | 0x00 | All flags cleared |
1 | 00000001 | 0x01 | Least significant bit set |
15 | 00001111 | 0x0F | Lower nibble mask |
255 | 11111111 | 0xFF | All bits in one byte set |
Bitwise Operations Calculation Steps
To calculate a bitwise operation, convert the values to binary, align equal place values, apply the operator to each column, and convert the result to the required number system.
Operation Step Visualizer
12 & 25 = 8
How to Calculate Bitwise AND
To calculate bitwise AND, align both binary values and write 1 only where both bits are 1.
- Convert decimal or hex input to binary.
- Pad the shorter value with leading zeros.
- Compare each aligned bit pair with the AND rule.
- Example:
00001100 & 00011001 = 00001000, which equals decimal 8.
How to Calculate Bitwise OR
To calculate bitwise OR, align both binary values and write 1 where either bit is 1.
- Convert both inputs to binary.
- Match positions from right to left.
- Apply the OR rule to every bit pair.
- Example:
00001100 | 00011001 = 00011101, which equals decimal 29.
How to Calculate Bitwise XOR
To calculate bitwise XOR, write 1 where the two bits differ and 0 where the bits match.
- Align both binary values.
- Mark each unequal bit pair with 1.
- Mark each equal bit pair with 0.
- Example:
00001100 ^ 00011001 = 00010101, which equals decimal 21.
How to Calculate Bitwise NOT
To calculate bitwise NOT, choose a width and invert every bit in one input value.
- Write Number A at the selected width.
- Replace every 1 with 0 and every 0 with 1.
- Interpret the output as unsigned or signed two's complement.
- Example: 8-bit
~00001100 = 11110011, which equals unsigned decimal 243.
How to Calculate Bitwise Left Shift
To calculate a left shift, move each bit left by the selected count and fill the right side with zeros.
- Choose the shift count
n. - Move every bit left by
npositions. - Discard high bits that overflow a fixed width.
- Example:
00001100 << 2 = 00110000, which equals decimal 48.
How to Calculate Bitwise Right Shift
To calculate a logical right shift, move each bit right and fill the left side with zeros.
- Choose the shift count
n. - Move every bit right by
npositions. - Discard low bits that pass the right edge.
- Example:
00001100 >> 2 = 00000011, which equals decimal 3.
Why Use This Bitwise Calculator?
This Bitwise Calculator makes binary arithmetic visible and checkable. The tool combines input conversion, operator rules, fixed-width behavior, result formats, and visual bit diagrams in one page.
Bit Width Preview
Bitwise Operator Calculator with Steps
The bitwise calculator with steps aligns Number A, Number B, and the result by position. Each column shows why the selected operator returns 0 or 1.
Supports Binary, Decimal & Hexadecimal
Enter values in binary, decimal, or hexadecimal. Built-in number system conversion displays equivalent output without opening separate Number System Converters.
Visual Bit Diagrams
Visual Bit Diagrams show active bits, changed bits, included zeros, leading zeros, and shift movement. The diagram connects each result bit to the input rule.
Configurable Bit Width
Choose Auto, 8-bit, 16-bit, 32-bit, or 64-bit. Fixed widths preserve leading zeros and make overflow, masking, sign bits, and bitwise NOT results easier to inspect.
Fast & Accurate Online Calculation
The calculation runs locally in the browser and updates when an input, operator, format, or width changes. No account, upload, or server request is required.
Practical Applications of Bitwise Operations
Bitwise operations store and process multiple binary states inside one integer. Six common applications are permissions, feature flags, masks, embedded registers, network fields, and graphics channels.
Permission and Access Control
Operating systems encode read, write, and execute permissions as flags. Bitwise OR combines permissions, bitwise AND checks access, and bitwise NOT helps clear selected permission bits.
Feature Flags
Applications assign one bit to each enabled or disabled feature. OR sets a flag, AND tests a flag, XOR toggles a flag, and an inverse mask clears a flag without changing the others.
Bit Masking
Masking isolates fields inside a larger integer. A mask can extract a hex nibble, detect a zero flag, clear a bit without branching, or remove unused high bits.
Embedded Systems
Firmware reads and writes device registers with masks and shifts. One register can hold sensor states, control flags, error codes, and pin settings in separate bit positions.
Networking and Protocols
Network software decodes packed headers with shifts and masks. Subnet calculations, encryption routines, checksums, packet flags, port fields, and protocol values all depend on precise bit positions.
Graphics and Image Processing
Graphics code packs red, green, blue, and alpha channels into integer values. Shifts position each channel, masks extract channels, and OR combines channels into one pixel value.
Frequently Asked Questions
Find answers to common questions about bitwise operations and this online tool.