Tech & Web
Number Base Converter
Convert numbers between binary, octal, decimal, hexadecimal, and custom bases (2 to 36).
Inputs
Results
Converted Output
11111111
Decimal representation
255
Hexadecimal representation
FF
How It Works
The base converter translates string values between base $N$ systems. First, it parses the input string into a standard base-10 integer representation using JavaScript's native radix parsing: $Integer = \text{parseInt}(String, Base_{from})$. Next, it formats the integer into the target string using the base transformation index: $TargetString = Integer.\text{toString}(Base_{to})$. Supported bases range from 2 (binary) up to 36.
Formula Used
Decimal Value = ∑ [Digit × Base_from^i]
To convert a number from base N to decimal, each digit is multiplied by the base raised to its positional power, and the terms are summed together.
Target String = SuccessiveDivide(Decimal, Base_to)
To convert a decimal number to base M, the number is repeatedly divided by base M. The remainders of each division form the digits of the target representation in reverse order.
Worked Example
Here is a step-by-step example of how these values are calculated:
Input
255 (Base 10)
To Base
Binary (Base 2)
Result: Binary: `11111111`. Decimal: `255`. Hexadecimal: `0xFF`.
Frequently Asked Questions
What happens if I type an invalid character for the selected base?
If you input a character not supported by the input base (e.g. typing 'F' in binary), the parser will read only up to the first invalid character or return `NaN` (Not a Number) if the first character is invalid.
What is base 36?
Base 36 represents numbers using the standard ten Arabic numerals (0-9) followed by all 26 Latin letters (A-Z), where 'Z' is equal to 35.