Programmer's Calculator

Type full expressions like (0xFF << 2) | 0b1010 — see the result in hex, decimal, octal, and binary at once.

Hexadecimal
Decimal
Octal
Binary

Bare numbers are read in the Input base — set it to Hex and FF + 1 just works. Prefixes always win regardless: 0x2F hex, 0b1010 binary, 0o17 octal. Operators: + - * / %, shifts << >>, bitwise & | ^ ~, parentheses. Press Enter to save an expression to history; click bits to toggle them.

    What this calculator does

    Instead of pushing buttons on a fake keypad, type the whole expression the way you'd write it in code — mixing bases freely. (0xFF << 2) | 0b1010, 1 << 20, 0xDEADBEEF & 0xFFFF — the result appears in hexadecimal, decimal, octal, and binary simultaneously, along with a bit grid you can click to nudge individual bits.

    Arithmetic runs at arbitrary precision, then the result is truncated to your chosen word size, exactly like storing into a fixed-width register. If truncation changed the value, a warning shows the untruncated result — no silent wraparound surprises.

    Operators, highest precedence first

    OperatorsMeaning
    ~   -   (unary)bitwise NOT, negation
    *   /   %multiply, integer divide, remainder
    +   -add, subtract
    <<   >>shift left, shift right (arithmetic)
    &bitwise AND
    ^bitwise XOR
    |bitwise OR

    This matches C/Go/Java precedence, including the classic gotcha that & binds looser than == would — use parentheses when in doubt, they always win.

    Everyday recipes

    • Extract a byte: (0x12345678 >> 16) & 0xFF → 0x34
    • Set bit 5: 0x41 | (1 << 5) → 0x61
    • Clear bit 0: 0x0F & ~1 → 0x0E
    • Round up to a power-of-two boundary: (1234 + 0xFFF) & ~0xFFF → 0x1000
    • Unpack RGB: (0x38D3F5 >> 8) & 0xFF → the green channel, 0xD3

    Frequently asked questions

    Why does −1 show as FFFF FFFF FFFF FFFF?
    That's two's complement: at a 64-bit word size, −1 and the all-ones pattern are the same register contents. Switch "Decimal as" to signed to see −1, or to unsigned to see 18,446,744,073,709,551,615 — same bits either way.
    Is >> a logical or arithmetic shift?
    Arithmetic (sign-preserving), matching what C, Go, and Java do to signed values. For a logical shift, mask first: (x & 0xFFFFFFFF) >> 4.
    Can it handle numbers beyond 64 bits?
    Yes — choose the Unlimited word size and results are exact at any width, useful for crypto constants and big bit masks. The other word sizes exist precisely to show you what a real register would keep.
    Just need to convert a number between bases?
    The number base converter is quicker for that, and handles any base from 2 to 36.