How this bitwise calculator evaluates integer bits
Bitwise operators act on the separate binary digits of an integer rather than treating the number as one ordinary arithmetic quantity. This calculator accepts decimal, binary, or hexadecimal integers and applies AND, OR, XOR, NOT, left shift, or right shift. It then presents the same result in decimal, binary, and hexadecimal, letting you inspect both its numerical value and its underlying bit pattern.
That view is useful whenever individual bit positions carry meaning. Masks, permission flags, packed fields, protocol values, microcontroller registers, graphics data, and low-level debugging all depend on patterns of on and off bits. A decimal-only answer can conceal why an operation produced a value; the binary display makes it clear which positions were retained, set, flipped, removed, or moved.
Start by selecting the base in which both inputs are written. In decimal mode, 15 means fifteen; in binary mode that entry is invalid because only 0 and 1 are valid digits. In hexadecimal, FF represents decimal 255. Matching prefixes are accepted too, including 0b1010 for binary and 0x1F for hexadecimal. A leading minus sign is permitted when you need to examine signed integer behavior.
What each bitwise calculator input means
For this bitwise calculator, First Number supplies the value to transform. Second Number is the other operand for AND, OR, and XOR, and is the count of positions for either shift operation. NOT is the exception: it inverts only the first number and ignores the second field. Because the calculator uses signed integer bitwise behavior, NOT does not assume an unsigned register width.
It helps to read a binary integer as a row of independent columns. Each column is either 0 or 1 and represents a power of two: 1, 2, 4, 8, 16, and onward from right to left. Bitwise operators compare or relocate those columns directly, which is why converting a decimal value to binary often makes the result easier to predict.
| Operator |
Plain-language meaning |
Quick example using 5 and 3 |
| AND |
Keeps a 1 only where both numbers have a 1 in the same bit position. |
0101 AND 0011 = 0001, so 5 AND 3 = 1. |
| OR |
Keeps a 1 wherever either number has a 1. |
0101 OR 0011 = 0111, so 5 OR 3 = 7. |
| XOR |
Keeps a 1 where the bits are different and a 0 where they match. |
0101 XOR 0011 = 0110, so 5 XOR 3 = 6. |
| NOT |
Flips every bit of the first number. |
For signed integers, NOT 5 becomes -6. |
| Left Shift |
Moves the first number's bits left by the second number of positions. |
5 << 3 = 40 because 0101 becomes 101000. |
| Right Shift |
Moves the first number's bits right by the second number of positions. |
5 >> 3 = 0 because 0101 becomes 0000. |
Formula view: bitwise logic is column-by-column logic
Bitwise operations are defined by the values in corresponding binary columns, rather than by a single arithmetic formula. For AND, OR, and XOR, if ai and bi are the bits at position i, the resulting bit is determined by the selected logical operator.
Shift operations instead move the entire binary pattern. For a nonnegative integer, shifting left by b places is equivalent to multiplying by 2b. A right shift moves positions in the other direction; for nonnegative values, it corresponds to division by 2b with any remainder discarded. The bit movement itself remains the most reliable way to interpret a shift.
NOT deserves separate attention because it changes every bit of its first operand. In signed integer notation, inversion is interpreted using two's-complement behavior rather than as a finite row of bits with an automatically chosen width. Choose a target width yourself when comparing the output with a hardware register, byte, or fixed-width textbook example.
Worked example with the default bitwise values
The default bitwise inputs, 5 and 3, make a compact example because their binary representations are 0101 and 0011. Compare the aligned columns from right to left to see how each two-input operator treats the same pair of values.
For AND, only the rightmost column contains a 1 in both values, giving 0001, or decimal 1. With OR, every column containing at least one 1 remains set, yielding 0111, or 7. XOR sets only the columns that differ, so 0101 XOR 0011 = 0110, which is 6. Looking at these three results together is a practical way to separate the rules: AND finds shared set bits, OR combines set bits, and XOR identifies differences.
The same values illustrate shifts. 5 << 3 moves 0101 three positions to the left, producing 101000, which is decimal 40 and hexadecimal 28. 5 >> 3 moves the pattern three positions to the right and leaves 0. This kind of movement is central to packing fields, making masks, and extracting pieces of a larger integer.
NOT can look unexpected if you expect a fixed four-bit answer. In a four-bit illustration, inverting 0101 gives 1010, but this calculator does not assume four bits. Its signed integer operation returns ~5 = -6. That result is appropriate for signed two's-complement semantics; apply the width of your own 8-bit, 16-bit, or other target system when interpreting an unsigned pattern.
How to read the bitwise result panel
The bitwise result panel displays one calculated integer in three number systems so you can choose the view that best fits the task. Decimal is useful for comparing magnitude, binary exposes exact bit positions and masks, and hexadecimal gives a compact representation in which every digit corresponds to four bits. For example, a mask such as 0xF0 is often easiest to recognize in hexadecimal and easiest to diagnose in binary.
Negative results appear as signed decimal, binary, and hexadecimal strings rather than as padded register dumps. Do not treat a negative binary or hexadecimal output as an already-sized 8-bit or 32-bit value. For hardware or protocol work, determine the appropriate width and signedness from the system you are targeting.
Bitwise assumptions, limits, and good habits
This bitwise calculator accepts integers, not fractions. Entries such as 3.5 are invalid because a bitwise operation works on whole-number bit patterns. It also validates input digits against the selected base: binary permits 0 and 1, decimal permits base-10 digits, and hexadecimal permits 0 through 9 plus A through F. Recheck an entry after changing bases, since the same text can represent a different value in another base.
Before relying on a bitwise result, decide whether your context requires a mathematical signed integer, an unsigned value, or a fixed-width stored pattern. These interpretations are related but not interchangeable. In particular, right shifts of negative values preserve the sign, which differs from an unsigned logical shift used in some programming environments. The calculator is well suited to learning and quick verification, while the final interpretation must match your language, register width, or data format.
Use the decimal, binary, and hexadecimal outputs together rather than treating any one as the whole answer. Select the correct base, choose the intended operator, and inspect the bit pattern after calculation. That process makes AND, OR, XOR, NOT, and shifts predictable instead of opaque symbols.
Enter numbers and choose an operation.
Tip: the NOT operator can return a negative number because the calculator follows signed integer bitwise behavior. For example, NOT 5 becomes -6, even though a fixed-width classroom example might show an unsigned bit pattern such as 1010.