Bitwise Calculator

Apply bitwise AND, OR, XOR, NOT, NAND and NOR and bit shifts to integers.

  • Runs locally in your browser
  • No upload required

Try it

Required for binary operators and shifts; ignored by NOT.

Result
8
Unsigned
8
Hexadecimal
0x00000008
Binary
00000000000000000000000000001000
Formula
12 and 10 = 8

Supported formats

Input
number, select
Output
number, text

Privacy

Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.

Processing
In your browser
Privacy level
Browser only

12 and 10 = 8 (hex 0x00000008).

How it works

  • Parsed both operands as 32-bit signed integers.
  • Applied bitwise AND (1 where both bits are 1).
  • Masked the result to 32 bits and rendered the hexadecimal and binary views.
textSelect to copy
12 and 10 = 8
  • Shifts use the low 5 bits of the shift count (0–31), matching JavaScript and most hardware.
  • The binary view shows the unsigned 32-bit two's-complement representation.

Methodology

  1. Coerce both operands to 32-bit signed integers using ToInt32.
  2. Apply the selected bitwise operator (or the operator followed by a full-width NOT for NAND/NOR).
  3. For shifts, take the shift count modulo 32 and shift within the 32-bit word.
  4. Render the signed decimal result together with its unsigned, hexadecimal and binary views.

Usage

  1. Choose the bitwise operator.
  2. Enter the first (and, for binary operators and shifts, the second) integer.
  3. Read the decimal, hexadecimal and 32-bit binary results.

Examples

These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.

12 AND 10

jsonSelect to copy
{
  "op": "and",
  "a": 12,
  "b": 10
}

12 OR 10

jsonSelect to copy
{
  "op": "or",
  "a": 12,
  "b": 10
}

12 XOR 10

jsonSelect to copy
{
  "op": "xor",
  "a": 12,
  "b": 10
}

NOT 0

jsonSelect to copy
{
  "op": "not",
  "a": 0
}

1 shifted left by 4

jsonSelect to copy
{
  "op": "shl",
  "a": 1,
  "b": 4
}

Limitations

32-bit words and two's complement

Bitwise operators in JavaScript and in this tool operate on 32-bit two's-complement words. That is why hex 0xFFFFFFFF and decimal -1 are the same bit pattern, and why shifts wrap at 32 bits.

NAND and NOR are implemented as a bitwise AND/OR followed by a bitwise NOT, so the result respects the same 32-bit word width as the other operators.

Frequently asked questions

Why does NOT 0 return -1?
JavaScript bitwise operators work on 32-bit two's-complement integers. Inverting all 32 bits of 0 gives 0xFFFFFFFF, which is -1 when read as a signed 32-bit integer.
What is the difference between >> and >>>?
>> is an arithmetic shift that preserves the sign bit (so a negative number stays negative); >>> is a logical shift that fills with zeros and always yields an unsigned result.
What do NAND and NOR mean?
They are the negations of AND and OR: NAND is NOT (a AND b), NOR is NOT (a OR b). Both are implemented by combining the operator with a full-width NOT.

Sources

  1. ECMAScript Language Specification — Bitwise Shift Operators and Binary Bitwise Operators — Ecma International
  2. MDN Web Docs — Bitwise operators — MDN