Bitwise Operator Calculator (AND, OR, XOR, NOT)
Apply bitwise logic operations to two integers and view the result in decimal, zero-padded binary, and hexadecimal.
Operation
Bit width
Binary: 00001000 • Hex: 0x8
How does this calculator work?
This tool applies bitwise AND, OR, XOR, NOT, NAND, NOR, or XNOR to two integers at a chosen width of 8, 16, 32, or 64 bits. Operands are masked to the width, the operation runs bit by bit, and the result is shown in decimal, zero-padded binary, and hexadecimal.
Formula
How this is calculated
Enter integer a and, for two-operand operations, integer b in decimal. Choose an operation (AND, OR, XOR, NOT, NAND, NOR, XNOR) and a bit width of 8, 16, 32, or 64. The calculator parses each input as an arbitrary-precision integer (BigInt) so even 64-bit values stay exact.
Each value is first reduced to the chosen width with a bit mask, mask = (1 << width) − 1. AND, OR, and XOR combine the two masked operands bit by bit. NOT inverts every bit of a, and NAND/NOR/XNOR are the inverses of AND/OR/XOR. Because inversion produces leading 1-bits, the result is masked again so it never exceeds the selected width — this is how the value wraps in fixed-width hardware registers.
The final result is shown three ways: as a decimal integer, as a zero-padded binary string matching the bit width, and as uppercase hexadecimal. Inputs are interpreted as unsigned within the chosen width; the b field is ignored for the single-operand NOT operation.
Frequently asked questions
NOT flips every bit within the chosen width. For 8-bit, ~12 inverts all 8 bits, giving 243. A wider bit width yields an even larger unsigned result, which is why the mask and width matter.
No. NOT is a unary operation that only uses a, so the b field is ignored when NOT is selected.
Values are masked to the selected bit width, so they are treated as unsigned within that width. A negative input is reduced modulo 2^width before the operation.
Also known as
TG we-Calculate Editorial Team. (2026). Bitwise Operator Calculator (AND, OR, XOR, NOT) [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/bitwise-operator-calculator
TG we-Calculate Editorial Team. "Bitwise Operator Calculator (AND, OR, XOR, NOT)." TG we-Calculate. 2026. https://we-calculate.com/calculator/bitwise-operator-calculator.
TG we-Calculate Editorial Team, "Bitwise Operator Calculator (AND, OR, XOR, NOT)," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/bitwise-operator-calculator
@misc{wecalculate_bitwise_operator_calculator, title = {Bitwise Operator Calculator (AND, OR, XOR, NOT)}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/bitwise-operator-calculator}}, year = {2026}, note = {TG we-Calculate} }
Did this calculator help you?
