calculator.onl
Categories50

Bitwise calculator: AND, OR, XOR and shifts

Compare fixed-width integer words in hexadecimal, binary and decimal. Click individual bits and see how masks, signed interpretation and shifts change the result.

A worked example

Switch AND to XOR. Which lamps light up for the same inputs?

Hexadecimal0xC0Binary11000000Decimal192Overflow or truncationNo overflow
Input base: Hexadecimal / Binary / Decimal.

Word width: 8 bit / 16 bit / 32 bit / 64 bit / 128 bit.

Unsigned / Signed two’s complement: Unsigned / Signed two’s complement.

A: HEX F0; BIN 11110000; DEC 240. ≤160.

Operation: AND / OR / XOR / NOT / Left shift / Logical right shift / Arithmetic right shift.

B: HEX CC; BIN 11001100; DEC 204. ≤160.

Updates as you type

Use a dot or comma for decimals. No thousands separators.

YOUR RESULT

Hexadecimal

0xC0

Calculated from your inputs

Binary11000000
Decimal192
Overflow or truncationNo overflow
The numbers, at a glance

Calculations run in your browser.
UNDERSTAND THE RESULT

A little context. A clearer answer.

↑ Back to calculator

When this calculator is useful

AND keeps only bits set in both operands, while OR also keeps a bit set in just one of them. Change “Operation” from AND to OR and keep the other inputs from the worked example. The value for “Hexadecimal” goes from 0xC0 to 0xFC. For a related calculation, try Big number calculator with exact decimals.

What to enter

InputWhat it meansExample value
Input baseInput base: Hexadecimal / Binary / Decimal.Hexadecimal
Word widthWord width: 8 bit / 16 bit / 32 bit / 64 bit / 128 bit.8 bit
Unsigned / Signed two’s complementUnsigned / Signed two’s complement: Unsigned / Signed two’s complement.Unsigned
Word AA: HEX F0; BIN 11110000; DEC 240. ≤160.F0
OperationOperation: AND / OR / XOR / NOT / Left shift / Logical right shift / Arithmetic right shift.AND
Word BB: HEX CC; BIN 11001100; DEC 204. ≤160.CC
Shift distanceShift distance: 0 … 128.—

How the calculation works

  1. Compare fixed-width integer words in hexadecimal, binary and decimal. Click individual bits and see how masks, signed interpretation and shifts change the result.
  2. Input base: Hexadecimal / Binary / Decimal. Word width: 8 bit / 16 bit / 32 bit / 64 bit / 128 bit. Unsigned / Signed two’s complement: Unsigned / Signed two’s complement. A: HEX F0; BIN 11110000; DEC 240. ≤160. Operation: AND / OR / XOR / NOT / Left shift / Logical right shift / Arithmetic right shift. B: HEX CC; BIN 11001100; DEC 204. ≤160. Shift distance: 0 … 128.
  3. Read the result and compare it with the diagram.
The formulam = 2ʷ−1; u = n & m; s = u ≥ 2ʷ⁻¹ ? u−2ʷ : u

A worked example

Bitwise calculator: AND, OR, XOR and shifts: 8 bit: 0xF0 AND 0xCC = 0xC0; XOR = 0x3C; NOT 0x00 = 0xFF.

Example you can load

What to enter
Result for this example · Hexadecimal0xC0

This is a fixed example; changing the form above does not change these numbers.

Assumptions & limits

Choose 8, 16, 32, 64 or 128 bits. Inputs outside the range are masked and flagged. Signed decimal input uses two’s complement; HEX and BIN may describe the full bit pattern. Arithmetic right shift extends the top bit, even when the output is displayed unsigned. Shifts are limited to 0–128.

Reference ·

Frequently asked questions

How is the result calculated?

Compare fixed-width integer words in hexadecimal, binary and decimal. Click individual bits and see how masks, signed interpretation and shifts change the result. m = 2ʷ−1; u = n & m; s = u ≥ 2ʷ⁻¹ ? u−2ʷ : u

How should I enter the values?

Bitwise calculator: AND, OR, XOR and shifts: 8 bit: 0xF0 AND 0xCC = 0xC0; XOR = 0x3C; NOT 0x00 = 0xFF.

What are the limits?

Choose 8, 16, 32, 64 or 128 bits. Inputs outside the range are masked and flagged. Signed decimal input uses two’s complement; HEX and BIN may describe the full bit pattern. Arithmetic right shift extends the top bit, even when the output is displayed unsigned. Shifts are limited to 0–128.