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
Supported formats
Privacy
Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.
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.
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
- Coerce both operands to 32-bit signed integers using ToInt32.
- Apply the selected bitwise operator (or the operator followed by a full-width NOT for NAND/NOR).
- For shifts, take the shift count modulo 32 and shift within the 32-bit word.
- Render the signed decimal result together with its unsigned, hexadecimal and binary views.
Usage
- Choose the bitwise operator.
- Enter the first (and, for binary operators and shifts, the second) integer.
- 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
{
"op": "and",
"a": 12,
"b": 10
}12 OR 10
{
"op": "or",
"a": 12,
"b": 10
}12 XOR 10
{
"op": "xor",
"a": 12,
"b": 10
}NOT 0
{
"op": "not",
"a": 0
}1 shifted left by 4
{
"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
Send feedback
Tell us if this tool helped, report a problem, or suggest a tool. Only the message you type is sent — never the input you used in the tool.
Was this tool useful?
Prefer to write to us directly? See the contact page.