## About the Base Converter

This is an *arbitrary-precision* number base converter, also known as a radix converter. It converts numbers from one base to another; for example: decimal (base 10) to hexadecimal (base 16), binary (base 2) to hexadecimal, duodecimal (base 12) to decimal, ternary (base 3) to binary, etc. It will convert between any pair of bases, 2 through 36.

This converter can convert fractional as well as integer values. For example, it will convert hexadecimal aaf1.e to binary 1010101011110001.111. It can convert very large and very small numbers (up to hundreds of digits). It allows you to specify one of several character sets for the digits (the default consists of the digits 0-9 and letters a-z).

## How to Use the Base Converter

### Input

section:*From***Enter a positive or negative number**with no commas or spaces, not expressed as a fraction or arithmetic calculation, and not in scientific notation. Fractional values are indicated with a radix point (‘.’,*not*‘,’)**Choose the base of the number**, from 2 through 36 (if different than the default). The most well-known bases are also described by name: binary (base 2), ternary (base 3), quaternary (base 4), quinary (base 5), senary (base 6), octal (base 8), decimal (base 10), duodecimal (base 12), hexadecimal (base 16), and vigesimal (base 20).**Choose the character set for the digits of the number**(if different than the default). You must use a character set with at least as many digits as the value of the base; the first*base*characters of the character set are used as the digit symbols. The position of a character in the set correlates to its numeric value (the first character has value 0). For bases requiring letters, the characters you enter must match the case of the characters in the chosen character set.There are three character sets specifically for base 12 (duodecimal, or

*dozenal*), although you can use them for any base less than or equal to 12. Each include the digits 0-9, but each has a different pair of characters for the ten and eleven symbols: X and E, T and E, and * and #. (You can also use a character set that has A and B or a and b serving as the ten and eleven symbols.)There are character sets that exclude the letters I (i), L (l), and O (o) — useful for bases 19 and higher — to eliminate confusion with 1 and 0. There are six combinations of these character sets: one that removes I (and one that removes i), one that removes I and L (and one that removes i and l), and one that removes I, L and O (and one that removes i, l, and o).

There are also character sets with no numeric digits; for example, where ‘a’ serves as 0 (be aware in this case that leading and trailing ‘a’s will be trimmed — they function as numeric zeros).

section:*To***Choose the base of the number**(as described above).**Choose the character set for the digits of the number**(as described above).**Change the number of fractional digits you want displayed**in an infinitely repeating fractional result, if different than the default (applies only when converting a fractional value). (These are*places*, not significant digits, so leading zeros are counted.)

**Click ‘Convert’**to convert.**Click ‘Swap From/To’**to do the conversion in the opposite direction. This will swap the bases and character sets, copy the “to” number to the “from” number field, and perform the conversion. (Truncated “to” values — those ending in ‘…’ — will be copied to the “from” field with the trailing ‘…’ removed.)**Click ‘Clear’**to reset the form and start from scratch.

If you change the base(es), character set(s), or number of fractional digits, you must click ‘Convert’ (or ‘Swap From/To’) for the conversion to take place.

If you want to convert another number with the same options, just type over the original number and click ‘Convert’.

### Output

Besides the converted result, the number of digits in both the original and converted numbers is displayed. For example, when converting decimal 192.25 to binary 11000000.01, the “Num Digits” box displays ‘3.2 to 8.2’. This means that the decimal input has three digits in its integer part and two digits in its fractional part, and the binary output has eight digits in its integer part and two digits in its fractional part.

Fractional values that convert to infinite (repeating) fractional values are truncated — not rounded — to the specified number of digits. In this case, an ellipsis (…) is appended to the end of the converted number, and the number of fractional digits is noted as infinite with the ‘∞’ symbol. Fractional values that terminate are displayed in full precision, regardless of the number of fractional digits specified.

## Exploring Properties of Base Conversion

Use this converter for a deeper understanding of base conversion; for example, to see how the number of digits correspond between different bases. Try converting some large ternary integers to base 20, for example. What is the ratio of the number of base 3 digits to base 20 digits? (Answer: it will approach log_{3}(20), which is approximately 2.73.)

How about the length of fractional values? Some will convert to an infinite string of digits, and some will terminate. For those that terminate, how do the number of digits correspond? For example, using the default character set, convert the base 3 number 0.22101220121221102 to base 9, 21, and 27. In base 9 it is 0.835655736 (17 digits to 9 digits, approximately 2:1); in base 21 it is 0.jcgi72edc4i7ff64e (17 digits to 17 digits, 1:1); in base 27 it is 0.p5jnm6 (17 digits to 6 digits, approximately 3:1). Are those ratios consistent across those base pairs? (Answer: Yes.) What determines whether a fractional is infinite or terminates, and how many digits it has if it terminates? (Answer: it has to do with the prime factors in both bases.)

## Implementation

This converter is implemented in arbitrary-precision decimal arithmetic. The conversion of a fractional value is done through an intermediate base *fraction*, not a fractional value; this prevents the intermediate representation from introducing error in the final converted result.

## Limits

For practical reasons, the size of the inputs — and the number of fractional digits in an infinite fractional result — is limited. If you exceed these limits, you will get an error message. But within these limits, all results will be accurate (in the case of infinite fractional results, results are accurate through the truncated digit).