Calcist

Style

Buttons

Spacing

How much to show

Decimal places

Text size

Programmer calculator

Convert a number between decimal, hex, binary and octal, see its bits, and do bitwise and whole-number math at the word size you choose.

Private: calculated on your device. Nothing you type is sent anywhere.

Number bases

Decimal uses ten digits (0–9). Binary uses two (0 and 1), octal eight (0–7) and hexadecimal sixteen (0–9 and A–F). 255 in decimal is 1111 1111 in binary and FF in hex. Each hex digit stands for exactly four binary digits, which is why programmers like hex: it's a short way to write bits.

Signed numbers and two's complement

In a signed number the top bit marks a negative. Computers store negatives in two's complement: flip every bit and add 1. In 8 bits, −1 is 1111 1111 (FF) and the range is −128 to 127; unsigned, the same 8 bits run from 0 to 255. If an answer doesn't fit in the word size, it wraps around, just like in a real program, and Calcist tells you when that happens.

Bitwise operations

  • AND keeps a 1 only where both numbers have one: 1100 AND 1010 = 1000.
  • OR keeps a 1 where either has one: 1100 OR 1010 = 1110.
  • XOR keeps a 1 where they differ: 1100 XOR 1010 = 0110.
  • NOT flips every bit.
  • Shift left by n multiplies by 2ⁿ; shift right divides by 2ⁿ and rounds down.

Learn: Binary, decimal and hexadecimal

Questions people ask

How do I convert decimal to binary?

Choose Decimal as the base and type the number: the binary, hex and octal versions appear underneath, with every bit shown.

How do I convert hex to decimal?

Choose Hexadecimal and type the hex digits, like FF or 0x1A3F.

What is two's complement?

The usual way computers store negative whole numbers: invert the bits of the positive number and add 1.

Why did my answer wrap around?

It didn't fit in the word size you chose. Pick a bigger word size, like 64-bit, to see the full value.

Related calculators