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.

Number A
Dec46 Hex0x2E
Number B
Dec74 Hex0x4A

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 bit 0 Diff bit 0 Included zero 0 Leading zero

Interactive Truth Table Matrix

Click a row to load values into A and B, or inspect how each gate behaves.

Input AInput BANDORXORNOT A
000001
010111
100110
111100
Click a truth table row to test those values.

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

A
&
B
Result0

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

Binary0010 1110
Decimal46
Hexadecimal0x2E

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.

DecimalBinary (8-bit)HexadecimalBit pattern use
0000000000x00All flags cleared
1000000010x01Least significant bit set
15000011110x0FLower nibble mask
255111111110xFFAll 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

A0000 1100 B0001 1001 RuleKeep 1 only where both bits are 1 Result0000 1000

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 n positions.
  • 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 n positions.
  • 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

10 1110
Auto: 6 active bits0 leading zeros

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 Mask Builder

r--
Binary mask100
Decimal4
Octal4
Combined with0 | 4 = 4

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.

How to Use the Bitwise Calculator

To use the Bitwise Calculator, select an input format, enter Number A and Number B, choose a bit width, and select AND, OR, XOR, or NOT. The result, bit-by-bit diagram, and number-format conversions update automatically.

What is the difference between logical and bitwise operators?

Logical operators evaluate whole conditions as true or false. Bitwise operators compare or change individual bits in integer values. For example, logical AND checks whether two conditions are true, while bitwise AND compares each aligned pair of binary digits.

When should you use bitwise operators?

Use bitwise operators when code needs to inspect, set, clear, toggle, combine, or shift individual bits. Common uses include permission masks, feature flags, packed data, device registers, network headers, color channels, checksums, and encryption routines.

Can I perform bitwise operations on binary numbers?

Yes. Select Binary and enter values containing only 0 and 1. The calculator aligns both bit strings and returns binary, decimal, and hexadecimal results.

Can I perform bitwise operations on hexadecimal numbers?

Yes. Select Hexadecimal and enter base-16 values with or without the 0x prefix. The calculator converts each hex digit to four bits before applying the selected operation.

Which number systems does this calculator support?

The calculator accepts binary, decimal, and hexadecimal input. It displays equivalent result values in those three number systems. Octal input is not currently supported.

Does this calculator show step-by-step calculations?

Yes. The visual bit diagram aligns the input bits and shows the result at each position. The page also explains the calculation rule and provides worked examples for every supported operator.

What bit widths are supported?

This calculator supports Auto, 8-bit, 16-bit, 32-bit, and 64-bit widths. Auto fits the active values, while a fixed width preserves leading zeros and controls NOT and overflow behavior.

Can I use this calculator for programming languages like C, C++, Java, and Python?

Yes. C, C++, Java, and Python use the same core AND, OR, XOR, NOT, left-shift, and right-shift rules. Fixed-width, signed-number, overflow, and right-shift behavior can differ by language and data type, so match the calculator width to the type used in code.

Why does the bitwise NOT operator return negative numbers?

Bitwise NOT can return a negative number when the result is interpreted as a signed two's-complement integer. In that representation, the highest bit is the sign bit and ~x equals -x - 1. The same bit pattern has a nonnegative value when interpreted as unsigned.

What are the real-world applications of bitwise operations?

Real-world applications include permissions, feature flags, bit masks, embedded-system registers, networking protocols, graphics, cryptography, checksums, error detection, data compression, and packed file formats.

Are bitwise operations faster than arithmetic operations?

Not always. Modern processors execute many bitwise and arithmetic instructions at similar speeds, and compilers optimize both. Bitwise operations are most useful when the task itself works on bits, masks, flags, or powers of two.

Is this bitwise calculator free to use?

Yes. This Bitwise Calculator is free to use, requires no account, and performs calculations locally in your browser.