Math
Bitwise Calculator
Pick an operation, enter one or two values in binary, decimal, octal, or hex, and set the register width.
The calculator lines the bits up, applies the rule column by column, and shows the result as a bit grid, a truth table, and in every base, including the signed reading for values with the top bit set.
How the values below are written. Results are always shown in every base.
Negative decimals are converted to two's complement at the chosen width.
Not used for NOT.
NOT and NAND/NOR depend on the width because every bit above the value is flipped too.
Try an example
Result
Result (binary)
—
- Decimal
- —
- Hexadecimal
- —
- Signed reading
- —
Student quick launch
Grade planning, algebra checks, and formulas students reach for most.
Study path
Use this calculator with
Follow these when you want the formula behind the answer, a short lesson, or nearby tools in the same topic.
What the bitwise calculator solves
Bitwise operators act on each bit position independently, which makes them the tool for flags, masks, permissions, and fast arithmetic tricks. AND clears bits, OR sets bits, XOR toggles bits, and NOT flips everything. Because NOT, NAND, and NOR flip the unused high bits as well, the register width matters, so you choose it explicitly.
Truth table
| a | b | AND | OR | XOR | NAND | NOR | NOT a |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 1 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
How to use it
- Choose the operation. NOT uses only the first value.
- Set the input format to match how you typed the values (12 in decimal, 1100 in binary, C in hex).
- Pick the width. Values must fit; negative decimals are stored in two's complement.
- Read the grid: the top rows are the padded operands and the blue row is the result. The table lists every bit position.
How to read the answer
The result is shown at full width with nibble spacing. The unsigned decimal reads the bits as a plain The length or size of a vector, ignoring which way it points.; the signed reading treats the top bit as a sign bit, which is what NOT 12 = −13 in a signed byte means. Hex is the form you would use for a mask in code (0xF3).
Common mistakes and edge cases
- Confusing bitwise operators with logical ones: 12 AND 10 is 8, while the logical 12 && 10 is simply true.
- Forgetting width for NOT: NOT 12 is 11110011 (243) in 8 bits but 4294967283 in 32 bits.
- Values that do not fit the width are rejected, not silently truncated.
- XOR with the same value gives 0; XOR twice with a key restores the original (the basis of simple ciphers).
- AND with a power of two minus one (like 15) keeps only the low bits, a fast way to compute a remainder.
Worked examples
AND
12 AND 10
Result (binary)
00001000
OR
12 OR 10
Result (binary)
00001110
XOR
12 XOR 10
Result (binary)
00000110
NOT at 8 bits
NOT 12
Result (binary)
11110011
Hex mask
FF AND 0F
Result (binary)
00001111
NAND
1100 NAND 1010 (binary input)
Result (binary)
11110111
NOR with zero
0 NOR 0
Result (binary)
11111111
Negative operand
−1 AND 255 at 16 bits
Result (binary)
0000000011111111
Does not fit
300 AND 1 at 8 bits
Result (binary)
—
Frequently asked questions
What is the difference between AND, OR, and XOR?+
AND gives 1 only when both bits are 1 (12 AND 10 = 8). OR gives 1 when either bit is 1 (12 OR 10 = 14). XOR gives 1 when the bits differ (12 XOR 10 = 6).
Why does NOT depend on the bit width?+
NOT flips every bit in the register, including the leading zeros. NOT 12 is 11110011 in 8 bits (243, or −13 signed) but has many more ones in 32 bits.
How do bit masks work?+
AND with a mask keeps only the bits where the mask has 1s (x AND 0x0F keeps the low nibble). OR with a mask sets bits. XOR with a mask toggles bits.
What are NAND and NOR?+
NAND is NOT applied to AND, and NOR is NOT applied to OR. Either one alone can build every other logic gate, which is why they are common in hardware.
Can I use negative numbers?+
Yes. A negative decimal is converted to its two's complement pattern at the chosen width first. −1 is all ones, so −1 AND x = x.
About this calculator
- Written by
- mathcheck editorial team
- Last reviewed
- September 4, 2026
Method
- Uses the values entered by the user and stable formulas documented on the page.
Related calculators
Bit Shift Calculator
Left, logical right, and arithmetic right shifts at 4 to 64 bits with the before/after bit rows, bits shifted out, overflow detection, and the ×2^n or ÷2^n meaning of the shift.
Two's Complement Calculator
Convert decimal to two's complement and back at 4, 8, 16, 32, or 64 bits with the invert-and-add-1 steps, the sign bit highlighted, overflow detection, and the unsigned reading of the same bits.
One's Complement Calculator
Find the one's complement of a binary pattern by flipping every bit, encode a signed decimal in one's complement at a chosen width, or decode a pattern, with the two's complement shown for comparison.
Binary to Decimal Converter
Convert binary to decimal with the positional-weight table (bit × 2^n), fractional bits after the binary point, and an option to read the bits as a signed two's complement number.
Hex to Binary Converter
Convert hex to binary one nibble at a time: each hex digit becomes exactly four bits. Shows the nibble table, the decimal value, and octal, with fractional hex supported.
Binary Calculator
Add, subtract, multiply, or divide binary numbers with the column method shown: carries, borrows, partial products, and a long-division tableau, plus decimal, hex, and octal equivalents.
Last updated: September 4, 2026