HomeMath › Number Base Converter

Number Base Converter

Converts an integer written in one base (2–36) to another, using exact arbitrary-precision arithmetic, and always shows the binary, octal, decimal and hexadecimal forms.

When to use

You need to convert between binary, octal, decimal, hexadecimal or any positional base up to 36, including large integers.

Do not use when: The value has a fractional part, you need Roman numerals (use roman-numeral) or byte/bit unit conversions (use data-storage).

Formula

value = Σ dᵢ × from_base^i (digits read right to left); the result digits are the remainders of repeated division by to_base

Inputs

ParameterTypeUnitRequiredDescription
valuestringyesInteger written in the source base, e.g. 'ff' or '1010'. Letters a–z stand for digits 10–35 (case-insensitive); an optional leading '-' and the prefixes 0x, 0o, 0b are accepted.
from_baseintegerdefault 10Base of the input value. Range: ≥ 2, ≤ 36
to_baseintegerdefault 2Base of the result. Range: ≥ 2, ≤ 36

Outputs

OutputTypeUnitDescription
resultstringThe number written in to_base (digits above 9 as uppercase letters).
decimalstringExact base-10 representation (a string so that very large values are not rounded).
decimal_valuenumberBase-10 value as a number; omitted when it exceeds 2^53.
binarystringBase-2 representation.
octalstringBase-8 representation.
hexadecimalstringBase-16 representation.

Example

ff (hex) to decimal: {"value":"ff","from_base":16,"to_base":10}{"result":"255","decimal":"255","decimal_value":255,"binary":"11111111","octal":"377","hexadecimal":"FF"}

1010 (binary) to hex: {"value":"1010","from_base":2,"to_base":16}{"result":"A","decimal":"10","decimal_value":10,"binary":"1010","octal":"12"}

GET https://tttkmbb.com/api/v1/calculate/base-converter?value=ff&from_base=16&to_base=10

Machine access

Sources

FAQ

Are negative numbers supported?

Yes, with a leading minus sign (sign-magnitude form). Two's-complement bit patterns are not interpreted.

What about fractions like 0.1 in binary?

Not supported; only integers are converted. Multiply by a power of the base first if you need fixed-point digits.

Related calculators