Tool to write numbers in base N (change of basis / convert). In numeral systems, a base (radix) is the value of successive powers when writing a number.
Base N Convert - dCode
Tag(s) : Arithmetics
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
The base is the number of distinct digits used to represent numbers (in a positional number system).
Example: In base 10 (the decimal system used in most of the world), 10 digits are used: from 0 to 9. Each position of a digit represents a power of 10.
A number $ N_{(b)} $ written in base $ b $ is composed of $ n $ digits $ \{ c_{n-1}, c_{n-2}, \cdots, c_1, c_0 \} $, it can be written as a polynomial where the digits are the coefficients and the base $ b $ is the variable:
$$ N_{(b)} = \{ c_{n-1}, \cdots, c_1, c_0 \}_{(b)} = c_{n-1} \times b^{n-1} + \cdots + c_1 \times b^1 + c_0 \times b^0 $$
Example: The number $ N = 789_{(10)} $ (base 10) verifies the equality $$ N = 7 \times 100 + 8 \times 10 + 9 \times 1 = 7 \times 10^2 + 8 \times 10^1 + 9 \times 10^0 = 789 $$
To make a base change (from one base $ b_1 $ to another $ b_2 $), it will most often be necessary to first convert the number from base $ b_1 $ to base 10, then convert from base 10 to base $ b_2 $.
Example: To convert from base $ 3 $ to base $ 7 $, calculate from base $ 3 $ to base $ 10 $, then from base $ 10 $ to base $ 7 $
It is sometimes possible to convert directly from one base to another without going through base 10, if base $ b_2 $ is a power of base $ b_1 $, but this does not work for arbitrary bases.
Example: Converting directly from base 4 to base 16 is possible because $ 16 = 4^2 $
To convert a number $ N $ written in base 10 to base $ b $, use the successive division method:
1 - Divide $ N $ by $ b $
2 - Record the remainder $ r $ and the quotient $ q $
3 - Repeat steps 1 and 2, replacing $ N $ with the quotient $ q $ until you get a quotient of zero.
4 - The number converted to base $ b $ is obtained by reading the remainders from the last division (highest digit) to the first division (units digit).
Example: $ N = 123_{(10)} $ (base 10) converts to base $ 7 $: $$ N = 123 \\ r_0 = 123 \mbox{ mod } 7 = \fbox{4} \;\;\; q_0 = 123 \mbox{ div } 7 = 17 \\ r_1 = 17 \mbox{ mod } 7 = \fbox{3} \;\;\; q_1 = 17 \mbox{ div } 7 = 2 \\ r_2 = 2 \mbox{ mod } 7 = \fbox{2} \;\;\; q_2 = 2 \mbox{ div } 7 = 0 \\ 123_{(10)} = 234_{(7)} $$
To convert a number $ N_{(b)} $ from base $ b $ to base $ 10 $, the most direct method is to use the formula $$ N_{(10)} = c_{n-1} \times b^{n-1} + \cdots + c_1 \times b^1 + c_0 \times b^0 $$
Example: $ 123_{(7)} $ converts to base 10 by the calculation $ 1 \times 7^2 + 2 \times 7^1 + 3 \times 7^0 = 49 + 14 + 3 = 66 $ so $ 123_{(7)} $ is equal to $ 66_{(10)} $
Another method uses polynomial accumulation:
1 - Initialize the conversion by setting $ R = 0 $
2 - Scan the digits $ c_i $ from left to right and for each digit, perform: $ R = R \times b + c_i $
3 - The final result $ R $ corresponds to the value in base 10, $ N_{(10)} = R $
Example: Convert the number $ 123_{(7)} $ (written in base $ 7 $), apply steps 1 to 3: $$ \{1,2,3\}_{(7)} \, R = 0 \\ R = 0 \times 7 + 1 \\ R = 1 \times 7 + 2 = 9 \\ R = 9 \times 7 + 3 = 66 \\ R = 66_{(10)} $$ so $ 123_{(7)} $ is equal to $ 66_{(10)} $ in base $ 10 $
A number in base 10 (or lower bases) is written with the digits 0123456789. For higher bases, it is customary to use letters, and more specifically the following characters: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ to write numbers up to base 62.
From base 37 onwards, uppercase and lowercase letters must be clearly differentiated.
Other bases allow for the simplification of certain calculations or representations depending on the context.
Example: Base 2 is suitable for electronic circuits, base 16 simplifies the reading of binary numbers, and base 60 is used for measuring time.
— base 2 (binary system - base2) in informatics
— base 3 (trinary or ternary system - base3)
— base 8 (octal system - base8)
— base 9 (nonary system - base9)
— base 10 (decimal system - base10)
— base 12 (duodecimal system - base12), for month or hours
— base 16 (hexadecimal system - base16) in informatics for bytes
— base 20 (vigesimal system - base20) used by Mayan numeral system (and Aztecs)
— base 26 (alphabetic system - base26)
— base 27 (alphabetic system + special character - base27)
— base 36 (alphanumeric system - base36)
— base 37 (alphabetic system + special character - base37)
— base 60 (sexagesimal system - base60) for minutes, seconds by Sumerians and Babylonians.
— base 62 (full alphanumeric system - base62)
All the basics can be used for computer coding or any other math problem.
Example: Encoding and decoding base64 is common on the Internet.
dCode retains ownership of the "Base N Convert" source code. Any algorithm for the "Base N Convert" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Base N Convert" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Base N Convert" or any other element are not public (except explicit open source licence). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.
The content of the page "Base N Convert" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source (Creative Commons CC-BY free distribution license).
Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).
To cite dCode.fr on another website, use the link:
In a scientific article or book, the recommended bibliographic citation is: Base N Convert on dCode.fr [online website], retrieved on 2025-10-25,