Skip to content
gohacks.dev
Tooling

Bitwise Calculator

Calculate AND, OR, XOR, NOT and left, arithmetic right and logical right shifts on 8, 16, 32 or 64-bit integers, with results in binary, hex, unsigned and signed.

Free · No sign-up · Your inputs stay in your browser

Input

Bitwise calculator: AND, OR, XOR, NOT and shifts

Output

a & b

BinaryHexUnsigned / signed
a1011 01100xB6182 / -74
b0000 11110x0F15 / 15
result0000 01100x066 / 6

Values are truncated to the chosen width, the way a fixed-size integer behaves in C, Go, Rust or a database column. Unsigned and two's-complement signed readings of the same bits are both shown. The arithmetic shift copies the sign bit in from the left; the logical shift fills with zeros. AND with a mask tests bits, OR sets them, XOR toggles them.

Runs in this browser. Nothing you paste is sent to a server.

What each operation is for

AND with a mask tests or clears bits (flags & 0x04), OR sets them, XOR toggles them and is its own inverse, NOT flips every bit within the width. Shifts multiply or divide by powers of two; the arithmetic right shift keeps the sign of negative numbers, the logical one fills with zeros. Permission bits, feature flags, network masks and hash functions all use them.

Width changes the answer

~5 is 250 as an 8-bit unsigned value and 4294967290 as a 32-bit one. JavaScript's bitwise operators work on 32-bit signed integers, which is why 1 << 31 is negative there; BigInt operators have no width limit.

Share

Frequently asked questions

How do I check whether a bit is set?
AND the value with a mask that has only that bit: (value & (1 << n)) != 0.
What is the difference between >> and >>>?
>> is an arithmetic shift that copies the sign bit in from the left; >>> is a logical shift that fills with zeros. They differ only for negative numbers.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools