Bitwise Calculator — AND, OR, XOR and shifts
AND, OR, XOR, NOT and shifts with a live bit grid so you can see exactly which bits moved.
Example: 0xCA AND 0x0F = 0x0A (10, 0b00001010).
Check it against real silicon
Chiprun runs your firmware on an emulated microcontroller and hands back the UART output, so you can confirm these numbers rather than trusting them.
Formula
result = a ⊕ b, masked to the register widthWorked example
0xCA AND 0x0F = 0x0A (10, 0b00001010).
AND (a & b)
1100 1010 0000 1111
0000 1010
Frequently asked questions
How do I clear a specific bit?
AND with the complement of that bit: `x &= ~(1 << n)`. To set one, OR with it: `x |= (1 << n)`. To flip it, XOR: `x ^= (1 << n)`. To test it, AND and check for non-zero.
Is shifting left the same as multiplying by two?
Only while nothing overflows. Left-shifting a fixed-width value discards bits that fall off the top, so once the result exceeds the register width the equivalence breaks. This tool flags it when that happens.
Why do I get a different answer in JavaScript?
Because JavaScript's bitwise operators convert to signed 32-bit integers first. Any value above 2³¹−1, or any 64-bit operation, gives a wrong result. This calculator uses BigInt throughout to avoid exactly that.
What is the difference between logical and arithmetic right shift?
Arithmetic shift preserves the sign by copying the top bit in; logical shift brings in zeros. In C, shifting an unsigned type is logical and shifting a signed negative value is implementation-defined — which is a good reason to do bit manipulation on unsigned types only.
Related tools
Hex, Binary & Decimal Converter
Convert between hex, binary, decimal, octal and ASCII, with width-aware bit grids and endianness swapping.
Firmware
Two's Complement Calculator
Signed and unsigned interpretation at any register width, with overflow and carry flags.
Firmware
Register Bitfield Decoder
Paste a register value and a field layout to get a decoded table — with presets for common STM32 and AVR registers.
Firmware
CRC Calculator
CRC-8, CRC-16 (CCITT, Modbus, XMODEM) and CRC-32 over hex or ASCII input, with the polynomial and shift steps explained.
Firmware
IEEE 754 Float Converter
Convert between decimal, hex and binary float32/float64, with the sign, exponent and mantissa fields broken out.
Firmware
PWM Frequency & Duty Calculator
The frequency-versus-resolution trade-off made explicit, with register values for your MCU and duty-cycle counts.
Firmware