Bitwise Calculator

AND, OR, XOR, NOT, shifts, rotates and popcount on 8–64-bit integers — enter values in binary, hex, octal or decimal and read the result in every base, unsigned and signed. Runs entirely in your browser.

Try:
Result

About this tool

The bitwise calculator applies one bitwise operation to integers at a fixed bit width and shows the result in every common base at once. It covers the two-operand operations AND, OR and XOR, the one-operand operations NOT and popcount (count of set bits), plus logical shifts (shl, shr) and rotates (rotl, rotr). Everything runs locally in your browser — nothing is sent to a server.

Operands can be written in any base: plain digits are decimal, 0x57 is hex, 0b0101_0111 is binary, 0o127 is octal. Underscores or spaces may separate digits, and a leading - (e.g. -8) is read as two's complement at the chosen bit width. The result is rendered in binary (nibble-grouped), octal, decimal, hex and as a signed two's-complement value.

Worked example

87 AND 101 at 8 bits — align the binary to see which bits survive:

  0101 0111   (87, 0x57)
& 0110 0101   (101, 0x65)
= 0100 0101   (69, 0x45)

The tool prints that result in every base:

operation: 87 AND 101 (8-bit)
binary   : 0100 0101
octal    : 0o105
decimal  : 69
hex      : 0x45
signed   : 69

Limits

FAQ

How are negative numbers handled?

A leading - is interpreted as two's complement at the selected bit width, so -8 at 8 bits is the bit pattern 1111 1000 (240 unsigned). Results with the top bit set are shown both ways: the decimal line is the unsigned reading and the signed line is the two's-complement reading. Inputs below the signed minimum for the width (e.g. -129 at 8 bits) are rejected.

Is the right shift logical or arithmetic?

shr is a logical shift: vacated high bits are filled with 0, regardless of the sign bit. That matches >> on unsigned integers in C/Rust/Go and >>> in JavaScript/Java. An arithmetic (sign-propagating) right shift is not offered — if you need one on a negative value, divide the signed reading by a power of two instead.

What happens if I shift or rotate by more than the bit width?

Shifts are taken literally: shifting an 8-bit value by 8 or more pushes every bit off the edge, so the result is 0. Rotates wrap around instead — the count is reduced modulo the width, so rotl by 9 on an 8-bit value is the same as rotl by 1, and rotating by exactly the width returns the value unchanged.

Which input formats does the calculator accept?

Decimal (plain digits, e.g. 87), hex with 0x (e.g. 0x57), binary with 0b (e.g. 0b0101_0111) and octal with 0o (e.g. 0o127). Underscores and spaces between digits are ignored, so you can group long values for readability. The shift/rotate count in the second field accepts the same formats but must be non-negative.

Why does NOT return a large positive number?

NOT inverts every bit inside the selected width, and the decimal line always shows the unsigned reading of that pattern. NOT 0x0F at 8 bits is 1111 0000 = 240 unsigned — read the signed line (-16) for the two's-complement interpretation. Pick a larger or smaller bit width to control how many high bits get inverted.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool bitwise-calculator "87, 0x57, 0b0101_0111, or -8"

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/bitwise-calculator/?a=87%2C%200x57%2C%200b0101_0111%2C%20or%20-8&op=and&b=101%2C%200x65%20%E2%80%94%20or%20a%20count%20like%203%20for%20shifts&bits=32

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.