Programmer Calculator

Convert between hex, decimal, binary, and octal — and apply bitwise operators at any bit width.

Last reviewed: April 2026
Result
0x000000F0
0xFF AND 0x0F = 240
Decimal
240
Octal
0o360
Binary (32-bit)
0000 0000 0000 0000 0000 0000 1111 0000

How to Use This Programmer Calculator

Enter Value A in any common base — prefix with 0x for hexadecimal (0xDEADBEEF), 0b for binary (0b10110010), 0o for octal (0o755), or just type a plain decimal number. The calculator displays the value in all four bases simultaneously, so you can read off the conversion at a glance.

To apply a bitwise operator, select an operation from the dropdown and enter Value B. The result also appears in all four bases. Bit width controls the precision: at 8-bit, NOT 0 is 0xFF; at 32-bit, NOT 0 is 0xFFFFFFFF. Switch sign mode to read the same bits as either an unsigned integer or a signed two's-complement value.

What Each Operation Does

  • AND (&): result bit is 1 only when both A and B have a 1 in that position. Used to mask off bits — e.g. x AND 0xFF isolates the low byte.
  • OR (|): result bit is 1 when either A or B has a 1. Used to set bits — e.g. flags OR 0x04 sets bit 2 without disturbing the others.
  • XOR (^): result bit is 1 when exactly one of A or B has a 1. Used to toggle bits or detect differences. x XOR x = 0 always.
  • NOT (~): flips every bit of A. At 8-bit width, NOT 0x0F is 0xF0.
  • NAND, NOR: AND-then-NOT and OR-then-NOT respectively. NAND is the universal gate — every other boolean operation can be built from NAND alone, which is why it's the foundational building block of CMOS digital logic.
  • Shift left (<<): multiplies by powers of two. 3 << 4 equals 48.
  • Logical shift right (>>): divides by powers of two, filling vacated high bits with zero. Always treats the input as unsigned.
  • Arithmetic shift right (>> with sign extension): divides by powers of two, filling vacated high bits with the sign bit. Preserves sign for signed values.

Real-World Uses

This calculator is what every developer reaches for during low-level work: parsing binary file formats, debugging packed bit-flags, working out subnet masks, reading hex dumps, packing colors into RGBA integers ((R << 24) | (G << 16) | (B << 8) | A), checking if a value is a power of two (x AND (x - 1) == 0), and converting Unix file permissions between octal (0o755) and the rwxr-xr-x mental model.

It's also handy for embedded work where you need to construct a control register value bit-by-bit, or for reverse engineering when an integer value in a tool's UI doesn't match the bytes in a hex editor.

Common Mistakes

  • Forgetting the bit width: 0xFF AND 0xFF is 0xFF at 8-bit width but the same bits at 32-bit width is just 0x000000FF. The bit width controls how the result is displayed and how operators like NOT extend.
  • Confusing logical and arithmetic shift right: For unsigned values they behave identically. For signed negative values, arithmetic shift preserves the sign (-8 >> 1 = -4) while logical shift gives a large positive number.
  • Thinking signed conversion changes the bits: It doesn't. Signed and unsigned are just two interpretations of the same bit pattern. 0xFF at 8-bit unsigned is 255 and at 8-bit signed is -1 — same byte, different read.

Frequently Asked Questions

Type a hex literal directly into the value field — 0xFF, FF, or #ff all parse to 255. Decimal numbers parse as base-10. Binary literals start with 0b (e.g. 0b1011 = 11) and octal literals start with 0o (e.g. 0o755 = 493).
Bit width clamps the value and the result to that many bits. NOT 0 at 8-bit width is 0xFF. NOT 0 at 32-bit width is 0xFFFFFFFF. Shift operations also wrap at the chosen width.
Toggle the "Signed" option. With signed two's-complement on, the high bit is treated as the sign bit — so 0xFF at 8-bit width is -1, not 255. Switch to "Unsigned" to read the same bytes as a positive integer.
Yes — the calculator uses BigInt internally so 64-bit values stay precise. Operations on 8/16/32-bit widths are also exact; the result is masked to the width before display.
AND yields 1 only where both bits are 1. NAND is the negation: 1 everywhere except where both bits are 1. NAND is the universal gate — every other boolean operator can be built from NAND alone, which is why it's the building block of digital logic.