Bitwise Operations Calculator
Perform bitwise AND, OR, XOR, NOT, left shift, and right shift operations on integers. Enter values in decimal, binary (0b), or hexadecimal (0x) format.
Results will appear here.
Formulas
- AND (&): Each output bit is 1 only if both corresponding input bits are 1.
A & B - OR (|): Each output bit is 1 if at least one corresponding input bit is 1.
A | B - XOR (^): Each output bit is 1 if the corresponding input bits are different.
A ^ B - NOT (~): Each output bit is the complement of the input bit within the chosen bit width.
~A & mask - Left Shift (<<): Shifts bits of A left by B positions; equivalent to multiplying by 2B.
A << B - Right Shift (>>): Shifts bits of A right by B positions; equivalent to integer division by 2B.
A >> B
Assumptions & References
- Inputs are integers (whole numbers). Decimal, binary (0b prefix), and hexadecimal (0x prefix) formats are accepted.
- NOT operation applies a bitmask based on the selected bit width (8, 16, 32, or 64 bits) to produce an unsigned result.
- Left and right shift operations use 32-bit signed integer arithmetic (JavaScript bitwise standard).
- Binary output is grouped in nibbles (4 bits) for readability.
- Reference: IEEE 754 integer bitwise operations; Python / JavaScript bitwise operator semantics.
- Negative numbers are represented in two's complement for binary/hex display.