Bitwise Calculator
AND, OR, XOR, NOT and bit shifts on two integers — shown in binary, hex, unsigned and signed decimal, with selectable 8, 16, 32 or 64-bit width.
Accepts decimal, 0x hex, 0b binary, 0o octal (negatives allowed).
| Expression | Binary | Hex | Decimal | Signed |
|---|---|---|---|---|
| A | 0000 1100 | 0x0C | 12 | 12 |
| B | 0000 1010 | 0x0A | 10 | 10 |
| A & B | 0000 1000 | 0x08 | 8 | 8 |
| A | B | 0000 1110 | 0x0E | 14 | 14 |
| A ^ B | 0000 0110 | 0x06 | 6 | 6 |
| ~A | 1111 0011 | 0xF3 | 243 | -13 |
| ~B | 1111 0101 | 0xF5 | 245 | -11 |
| A << 1 | 0001 1000 | 0x18 | 24 | 24 |
| A >> 1 | 0000 0110 | 0x06 | 6 | 6 |
How to use
- Type two integers into A and B (decimal, or with a 0x / 0b / 0o prefix).
- Choose the bit width and a shift amount.
- Read each operation across binary, hex, unsigned and signed columns.
About this tool
ShowHide
Enter two integers and see every common bitwise operation at once: AND, OR, XOR, NOT (~A and ~B) and left/right shifts by any amount. Each result is shown in binary (grouped into nibbles), hexadecimal, unsigned decimal and two's-complement signed decimal. Pick an 8, 16, 32 or 64-bit width and results wrap to that size, so NOT and shifts behave exactly like they would in C, Rust or a register. Inputs accept decimal, 0x hex, 0b binary and 0o octal, and negatives are interpreted as two's complement. Computed with arbitrary-precision integers, so 64-bit values stay exact. Great for embedded work, bit flags and masks, protocol decoding and learning how binary operations work.
Frequently asked questions
How are negative numbers handled?
They're interpreted as two's complement at the chosen width — for example −1 becomes all ones (0xFF at 8-bit). The signed column shows the two's-complement value of every result.
What does the bit width change?
It masks results to that many bits, which matters for NOT and shifts. ~12 is 0xF3 at 8-bit but 0xFFFFFFF3 at 32-bit, just like a fixed-size integer in C or a CPU register.
Can I enter hex or binary?
Yes — use a 0x prefix for hex (0xFF), 0b for binary (0b1010) or 0o for octal. Plain decimal works too.
Are 64-bit results exact?
Yes. The calculator uses arbitrary-precision integers internally, so 64-bit operations don't lose precision the way 32-bit JavaScript bit operators would.
Is the right shift arithmetic or logical?
Logical — it shifts the unsigned pattern, so zeros come in from the left and the sign bit is not preserved. At 8-bit, A = −1 is 0xFF and A >> 1 is 0x7F, decimal 127, not −1. That matches JavaScript's >>> and Java's >>>, not their >>. If you need the arithmetic behaviour that C gives a signed int, shift the magnitude and re-apply the sign yourself, or read the signed column with that in mind.
Why does the left shift differ from what my JavaScript console says?
Because JavaScript's << always truncates its operands to 32 bits regardless of the value, so 1 << 40 evaluates to 256 — 40 wraps to 8. Here the shift is done on arbitrary-precision integers and only then masked to the width you selected, so 1 << 40 at 64-bit is 1099511627776, which is what C gives on a uint64_t. Shifting by the width or more is defined here as producing 0, where C calls that undefined behaviour; the shift box is clamped to 0-64.
Related tools
Two's Complement Converter (8–64 bit)
Enter a decimal, hex, binary or octal value and see its 8/16/32/64-bit two's complement bit pattern, with signed and unsigned readings.
Convert
ASCII Code Table
Browse and search the 256-row ASCII / extended-ASCII table — decimal, hex, octal, binary, and the named control characters.
Developer
Number Base Converter
Convert numbers between binary, octal, decimal, and hexadecimal.
Convert
Byte Size Converter (KB / KiB / MB / MiB / ...)
Convert between decimal (KB, MB, GB — SI base 1000) and binary (KiB, MiB, GiB — IEC base 1024) byte units, plus bits.
Convert
Gray Code Converter
Convert between decimal, binary and reflected-binary Gray code, both directions, with an optional fixed bit width and a 0-7 reference table.
Convert
BCD Converter (Binary-Coded Decimal)
Convert decimal to and from 8421 binary-coded decimal — per-digit 4-bit nibbles, packed BCD hex bytes, and BCD validity checking.
Convert