NUMBER BASE CONVERTER

Number base converter

Enter a number and its base, get it in any other base.

How do I convert between number bases?

Choose the base the number is written in and the base you want. The calculator reads the digits, finds the value and writes it in the new base — exactly, even for very long numbers.

Which digits can I use?

0–9, then A = 10, B = 11 … Z = 35. A digit must be smaller than the base: base 16 uses 0–9 and A–F, base 36 uses all letters.

Example

FF in base 16 is 255 in base 10, 11111111 in base 2 and 73 in base 36.

Why convert to base 36?

It packs numbers into short strings using all ten digits and 26 letters, which is why it shows up in short IDs and codes.

Can I convert negative numbers?

Yes — put a minus sign in front. The calculator handles whole numbers; fractions are not supported.

How many digits will a number have in another base?

A positive whole number n needs ⌊log_b(n)⌋ + 1 digits in base b. So 255 needs 8 digits in base 2 (11111111), 2 in base 16 (FF) and 3 in base 10.

Why do programmers use hexadecimal?

One hex digit stands for exactly four binary digits, so a byte is always two hex digits (00 to FF) and long binary strings become short and readable. Base 8 works the same way with three bits per digit.

Does upper or lower case matter?

No. The letters a to z and A to Z mean the same digits. The result is shown in capitals.

How the conversion works

In base b, each digit has a place value that is a power of b, and the number is the sum of digit × place value. To convert to base 10, multiply each digit by its place value and add. To convert from base 10 to another base, divide repeatedly by the new base, keep each remainder, and read the remainders from the last to the first. The calculator does this with exact integer arithmetic, so there is no rounding error however many digits the number has.

Worked example

Convert 2026 to base 16. The repeated division goes: 2026 ÷ 16 = 126 remainder 10 (A); 126 ÷ 16 = 7 remainder 14 (E); 7 ÷ 16 = 0 remainder 7. Reading the remainders from last to first gives 7EA (with A for 10 and E for 14). To check, 7EA in base 16 is 7 × 256 + 14 × 16 + 10 = 2026. The same number is 11111101010 in base 2, 3752 in base 8 and 1KA in base 36.

Common mistakes

  • Using a digit that is too large for the base. The digit 8 does not exist in base 8, and G does not exist in base 16. The input must contain only digits smaller than the base.
  • Reading letters as hex in other bases. In base 36 the letters continue past F up to Z, so "1Z" in base 36 is 1 × 36 + 35 = 71, not a hex number.
  • Dropping or adding leading zeros. Leading zeros do not change the value, but fixed-width formats such as bytes keep them. The calculator shows the shortest form.

Sources and related calculators

Method: positional notation and radix conversion, as described in Donald Knuth, The Art of Computer Programming, volume 2, section 4.1. Related: binary converter, hex calculator and color converter.