Calcamaze

Binary, Hex & Number Base Converter

Convert whole numbers between binary, octal, decimal, hexadecimal and any base from 2 to 36, with the division steps.

Result

Binary (base 2)
11111111
Binary
1111 1111
Octal
377
Decimal
255
Hexadecimal
FF
Bits needed
8
Converting 255 to base 2 by repeated division (read the remainders bottom to top)
DivideQuotientRemainderDigit
255 ÷ 212711
127 ÷ 26311
63 ÷ 23111
31 ÷ 21511
15 ÷ 2711
7 ÷ 2311
3 ÷ 2111
1 ÷ 2011

Convert a whole number between binary, octal, decimal and hexadecimal — or any base from 2 to 36. Type the number, choose the base it is written in and the base you want, and you will see the answer in every common base plus the repeated-division steps used to get it.

Computers store everything in binary, and programmers write it more compactly in hexadecimal, where each digit stands for exactly four bits. Enter a number in binary, octal, decimal or hex and see it in the others.

What is a number base?

A number base, or radix, is how many different digits a positional number system uses. Everyday decimal is base 10, with digits 0–9; each place is worth ten times the place to its right. In base b, the places are worth 1, b, b², b³ and so on.

Computers work in binary (base 2), because each bit is either off or on. Long binary strings are hard to read, so programmers use hexadecimal (base 16, digits 0–9 and A–F) and sometimes octal (base 8) as shorthand: each hex digit stands for exactly four bits and each octal digit for three. Colours such as #FF8800, memory addresses and file permissions are all written this way.

Converting between bases changes how a number is written, not its value. Bases up to 36 can be written with the ten digits plus the 26 letters A–Z.

How to use the binary, hex & number base converter

  1. Enter the number, with or without a 0x or 0b prefix.
  2. Choose the base it is written in and the base you want.
  3. Read the result, along with binary, octal, decimal and hex.

Formula

value = dₖ·bᵏ + … + d₂·b² + d₁·b + d₀

Each digit is worth the base raised to its position, counting from 0 on the right. Binary 1011 is 1·8 + 0·4 + 1·2 + 1·1 = 11.

To convert a decimal number to another base, divide by the base repeatedly and write down the remainders; read from the last remainder to the first. Bases above 10 use letters for digits: A = 10, B = 11 … Z = 35.

Worked examples

Binary to decimal

Number
101101
From
Binary (base 2)
To
Decimal (base 10)
Decimal (base 10)
45
Binary
10 1101
Octal
55

Add the place values of each 1: 32 + 8 + 4 + 1 = 45.

Decimal to hexadecimal

Number
2026
From
Decimal (base 10)
To
Hexadecimal (base 16)
Hexadecimal (base 16)
7EA
Binary
111 1110 1010
Octal
3752

2026 ÷ 16 = 126 remainder 10 (A); 126 ÷ 16 = 7 remainder 14 (E); 7 ÷ 16 = 0 remainder 7. Reading the remainders from the bottom up gives 7EA.

A hex colour channel

Number
C8
From
Hexadecimal (base 16)
To
Decimal (base 10)
Decimal (base 10)
200
Binary
1100 1000
Octal
310

C is 12, so C8 = 12 × 16 + 8 = 200 — the red value in the colour #C80000.

The same numbers in different bases

DecimalBinaryOctalHexadecimal
0000
1111
21022
711177
81000108
10101012A
15111117F
16100002010
321000004020
64100000010040
100110010014464
25511111111377FF
256100000000400100
1,000111110100017503E8

Why hex is everywhere in computing

Because 16 is 2⁴, every hex digit maps to four binary digits and a byte always fits in two hex digits, from 00 to FF (0 to 255). Web colors use this: #FF8800 is red 255, green 136 (0x88) and blue 0, a strong orange.

Common mistakes

  • Reading the division remainders top to bottom. The first remainder is the last (rightmost) digit, so read them from the bottom up.
  • Using a digit that does not exist in the base, such as 2 in binary or 8 in octal.
  • Forgetting that hex letters are digits: A = 10 through F = 15, so 1F is 31, not 1 followed by F.
  • Reading the letter O as zero or l as one when copying a hex value. Hex uses only 0–9 and A–F.

Frequently asked questions

How do I convert binary to hexadecimal quickly?

Group the binary digits in fours from the right and replace each group with one hex digit: 1111 1010 is FA. Octal works the same way with groups of three.

Can I type prefixes like 0x or 0b?

Yes. 0x for hexadecimal, 0b for binary and 0o for octal are accepted when they match the “From” base. Spaces and underscores between digits are ignored.

Why is there a size limit?

Numbers are converted exactly up to 2⁵³ − 1 (9,007,199,254,740,991), the largest whole number a web browser can store without rounding. Negative numbers are shown with a minus sign rather than in two’s complement.

How do I convert decimal to binary by hand?

Divide by 2 repeatedly and write down the remainders, then read them from last to first. 13 → 6 r1 → 3 r0 → 1 r1 → 0 r1, so 13 is 1101 in binary.

Sources

  1. Base, Wolfram MathWorld
  2. Binary, Wolfram MathWorld
  3. Contemporary Mathematics, 4.3 Converting with Base Systems, OpenStax, Rice University

Last updated · Calculations checked by automated tests· Editorial policy