bitlvl
EN

Base converter

Type a number in any base and read it in all the others. Tick Show the working to see how the answer is reached.

How base conversion works

A number system's base (or radix) is how many digits it has. Decimal has ten (0–9), binary two (0 and 1), octal eight and hexadecimal sixteen (0–9 then A–F). The value of a written number is the sum of each digit multiplied by the base raised to the digit's position, counting from zero on the right.

So 1011 in binary is 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 8 + 0 + 2 + 1 = 11, and FF in hex is 15×16¹ + 15×16⁰ = 240 + 15 = 255.

Converting from decimal to another base

  1. Divide the number by the target base and write down the remainder.
  2. Divide the quotient again, and keep going until the quotient is 0.
  3. Read the remainders from last to first. That is the number in the new base.

For 11 → binary: 11 ÷ 2 = 5 r 1, 5 ÷ 2 = 2 r 1, 2 ÷ 2 = 1 r 0, 1 ÷ 2 = 0 r 1. Reading upward: 1011. The converter above prints these steps for any number you enter.

Hex and binary are the same thing in disguise

Because 16 = 2⁴, every hex digit is exactly four binary digits (a nibble). To convert between them, replace each hex digit with its 4-bit pattern and vice versa. 0xBEEF = 1011 1110 1110 1111. Octal works the same way with groups of three bits. That is why programmers prefer hex: it is a compact way to write bit patterns.

HexBinaryDecHexBinaryDec
000000810008
100011910019
200102A101010
300113B101111
401004C110012
501015D110113
601106E111014
701117F111115

Prefixes you will see in code

Most languages mark the base with a prefix: 0x1F for hex, 0b11111 for binary, 0o37 (or a leading 0 in C) for octal. This converter accepts all of them, and also ignores spaces, underscores and commas, so 1111_1111 and 1111 1111 both work.

Examples

255 in binary, octal and hex
1111 1111 · 377 · FF
0xDEADBEEF in decimal
3,735,928,559
1 000 000 in hex
0xF4240
−42 in hex
−2A (as a signed magnitude; for the two's-complement bit pattern use the two's complement tool)

Questions

How do I convert binary to decimal by hand?

Write the powers of two under the digits from right to left (1, 2, 4, 8, 16 …), then add up the powers that sit under a 1. For 1101 that is 8 + 4 + 1 = 13.

How do I convert decimal to hexadecimal?

Divide by 16 repeatedly and collect the remainders; remainders of 10–15 become A–F. 255 ÷ 16 = 15 r 15 → 15 ÷ 16 = 0 r 15, so 255 = FF. Or convert to binary first and read it in groups of four bits.

Why do programmers use hexadecimal?

One hex digit is exactly four bits, so a byte is always two hex digits. Memory addresses, colour codes, hashes and bit flags are easier to read and type as hex than as long binary strings, while the mapping to bits stays obvious.

Does this converter handle big numbers?

Yes. It uses arbitrary-precision integers, so values beyond 64 bits (for example 256-bit hashes written as decimal) are converted exactly, with no rounding.

How are negative numbers handled?

A leading minus sign is kept and the magnitude is converted (−10 becomes −1010 in binary). If you need the bit pattern a CPU would store, which is two's complement, use the two's complement tool, which lets you pick the bit width.

Is my input sent to a server?

No. The conversion runs in your browser. The site has no backend that receives your numbers.