calc.cihat.dev

Binary, decimal and hex converter

Type a whole number in binary, octal, decimal, hex or any base up to 36, and read it in all of them at once. The place-value sum and the division by 2 are written out.

Whole numbers of any length. Prefixes 0b, 0o and 0x are fine; spaces and underscores are ignored.

Binary (base 2)
–
Octal (base 8)
–
Decimal (base 10)
–
Hexadecimal (base 16)
–
Base 36
–

How to use it

  1. Type the number and choose the base it is written in. 0b, 0o and 0x prefixes are understood.
  2. Read binary, octal, decimal and hexadecimal together. Choose any other base from 2 to 36 for the last line.
  3. Follow the working under the results to see where each digit comes from, then copy them.

Place values

In any base, each digit is worth the digit times the base raised to its position, counting from 0 on the right. Binary 1011 is 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 8 + 0 + 2 + 1 = 11. Hexadecimal uses the letters A to F for 10 to 15, so 1F is 1×16 + 15 = 31.

To go from decimal to binary, divide by 2 again and again and keep the remainders; read them from the last to the first. 11 ÷ 2 = 5 remainder 1, 5 ÷ 2 = 2 remainder 1, 2 ÷ 2 = 1 remainder 0, 1 ÷ 2 = 0 remainder 1, so 11 is 1011.

Why hex and binary line up

One hexadecimal digit is exactly four binary digits, and one octal digit is three. That is why the binary result is grouped in fours: each group is one hex digit. 1111 0000 is F0, and 1010 1100 is AC.

The converter works on exact whole numbers of any size, with no 32-bit or 64-bit limit, so large values such as 2⁶⁴ stay correct to the last digit. Negative numbers keep their sign; two’s complement is not applied.

Questions people ask

How do I convert binary to decimal?

Multiply each digit by 2 to the power of its position, counting from 0 on the right, and add. 1101 = 8 + 4 + 0 + 1 = 13.

How do I convert decimal to hexadecimal?

Divide by 16 repeatedly and read the remainders backwards, writing 10 to 15 as A to F. 255 = 15 × 16 + 15, so FF.

What bases can I use?

Any base from 2 to 36. Bases above 10 use the letters A to Z as digits.

Does it handle negative numbers or fractions?

Negative whole numbers keep a minus sign. Fractions and two’s complement are not converted.

Is there a size limit?

Up to 2,000 digits in the base you type, worked out exactly.