Bitwise Calculator
Bitwise AND, OR, XOR, NOT, NAND, NOR, XNOR, shifts, and rotates in one calculator.
Result: A AND B
Enter both values to see the result in decimal, hex, binary, and octal.
AND truth table
| A | B | A AND B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Bitwise Calculator
An all-in-one calculator for bitwise operations on integers. Pick an operation, enter one or two values in decimal, hex, binary, or octal, and choose a bit width. The result is shown bit by bit and as unsigned decimal, signed (two's complement) decimal, hexadecimal, binary, and octal – each with a copy button.
Supported operations
| Operation | Symbol | Result bit is 1 when … |
|---|---|---|
| AND | a & b | both bits are 1 |
| OR | a | b | at least one bit is 1 |
| XOR | a ^ b | the bits differ |
| NOT | ~a | the bit of A is 0 |
| NAND | ~(a & b) | not both bits are 1 |
| NOR | ~(a | b) | both bits are 0 |
| XNOR | ~(a ^ b) | the bits are equal |
Shift and rotate operations move the bits of A by the number of positions in the second field:
- Left shift (
<<) – moves bits to the left and fills with zeros; each step multiplies by 2 (bits that fall off the top are discarded). - Logical right shift (
>>>) – moves bits to the right and fills with zeros; each step divides an unsigned value by 2. - Arithmetic right shift (
>>) – fills with copies of the sign bit, so negative numbers stay negative (−128 >> 1 = −64). - Rotate left / right – bits that fall off one end re-enter at the other, as in the
ROLandRORCPU instructions used by hash functions and ciphers.
Choosing the bit width
Bitwise results depend on the size of the integer. NOT 0 is 255 in 8 bits but 4,294,967,295 in 32 bits, and shifts discard different bits. Auto uses the smallest multiple of 8 bits that fits your inputs; choose 8, 16, 32, 64, or 128 bits to mimic uint8_t, short, int, long, or 128-bit types. Negative numbers are converted to two's complement within that width, and an error is shown if a value does not fit.
Input formats
With Auto input format, 0x means hexadecimal, 0b binary, 0o octal, and everything else decimal. You can also force one base for both inputs, for example to type hex values without the prefix. Underscores and spaces are ignored, so 1010_0101 is fine.
Single-operation pages with truth tables are available for AND, OR, XOR, NAND, NOR, and XNOR.
Frequently Asked Questions
What is a bitwise operation?
A bitwise operation works on the individual bits of integers. For AND, OR, and XOR each bit of the result is computed from the bits at the same position in the two inputs; shifts and rotates move bits to other positions.
What is the difference between >> and >>>?
>> is an arithmetic shift that keeps the sign by copying the highest bit, while >>> is a logical shift that always fills with zeros. They differ only for negative (signed) values.
Why is NOT 5 equal to 250?
In 8 bits, 5 is 00000101 and NOT flips every bit to 11111010, which is 250 unsigned or -6 signed. With a 32-bit width the unsigned result would be 4,294,967,290.
Can I use hex and binary inputs together?
Yes. With the Auto input format each value is read according to its prefix, so 0xFF and 0b1010 can be combined in one calculation.