Skip to content

Bitwise Calculator

Perform bitwise operations (AND, OR, XOR, NOT, shifts) with multi-format results

Bit manipulation without the headaches

You’re implementing feature flags and need to check if permissions & 0x04 gives you read access. Or you’re parsing a binary protocol and need to extract 3 bits from the middle of a byte. Or you just want to confirm that 255 & 0xF0 actually gives you 240 before you deploy.

That’s what this calculator does. Pick an operation, AND, OR, XOR, NOT, shifts, enter your values in whatever format makes sense (decimal, hex with 0x, binary with 0b, octal with 0o), and see the result in all four formats simultaneously. No need to fire up a REPL.

The operations

AND (&): both bits must be 1. This is how you mask and extract. 0xFF & 0x0F gives you the lower nibble.

OR (|): either bit can be 1. Use it to set flags: permissions | WRITE_FLAG.

XOR (^): bits must differ. Toggles things. Also the basis of half the crypto algorithms ever written.

NOT (~): flips every bit. On 32-bit signed integers, ~n equals -(n+1), which catches people off guard the first time.

Left Shift (<<): shove bits left, fill with zeros. Each shift doubles the value. 1 << 8 gives you 256.

Right Shift (>>): arithmetic shift, preserves the sign bit. Negative numbers stay negative.

Unsigned Right Shift (>>>): fills with zeros regardless of sign. Treats the number as unsigned 32-bit.

Patterns you’ll actually use

Check a flag: value & FLAG, non-zero means it’s set. Set a flag: value | FLAG. Clear a flag: value & ~FLAG. Toggle a flag: value ^ FLAG. Even/odd check: n & 1, 0 means even. Fast multiply by 2^k: n << k.

These show up in permission systems, binary protocols, graphics code, embedded systems, and anywhere else you’re working close to the hardware. The results display in decimal, hex, binary, and octal all at once, so you can verify against whatever format your code uses.

Everything’s 32-bit signed integers, matching JavaScript’s bitwise behavior. For number base conversions without bitwise ops, there’s the Number Base Converter.

FAQ

What input formats work?

Decimal (255), hex (0xFF), binary (0b11111111), or octal (0o377). The calculator detects the format from the prefix.

Right Shift vs Unsigned Right Shift?

>> preserves the sign bit, negative numbers stay negative. >>> always fills with zeros. On positive numbers, they’re identical. On negative numbers, >>> gives you a large positive value.

Can I debug my code with this?

That’s basically the point. Enter the same operands your code uses, pick the operation, compare the output. The multi-format display makes mismatches obvious.

Everything’s client-side?

Yes, nothing leaves your browser.

bitwise binary calculator AND OR XOR shift

Related Tools

More in Developer Tools