Computer Science · Digital & Computing
Number Base Converter
Convert any integer between binary (base-2), octal (base-8), decimal (base-10), and hexadecimal (base-16) in any direction.
Calculator
Formula
Any integer N can be converted from base b₁ to base b₂ by first converting to decimal (multiply each digit by b₁ raised to its position), then converting from decimal to the target base (repeated division by b₂).
Source: Knuth, D. E. — The Art of Computer Programming, Vol. 2. Addison-Wesley, 1997.
How it works
All base conversions work through decimal as an intermediate step. First, the input is parsed in its source base by multiplying each digit by the source base raised to its positional power. Then the decimal value is converted to the target base by repeated division, collecting remainders.
The four bases covered are the most common in computing: binary is the native language of processors, octal was historically used in Unix permissions and early computing, decimal is the everyday standard, and hexadecimal is used in memory addresses, color codes, and assembly language.
Worked example
Binary → Hex: Convert 11110100.
Binary to decimal: 128+64+32+16+0+4+0+0 = 244
Decimal to hex: 244÷16=15 rF, 15÷16=0 r15(F) → F4
Hex → Octal: Convert F4.
Hex to decimal: 15×16+4 = 244
Decimal to octal: 244÷8=30 r4, 30÷8=3 r6, 3÷8=0 r3 → 364
Limitations & notes
Handles non-negative integers only. Numbers above 53 bits may lose precision due to JavaScript's floating-point limit. Input must only contain valid digits for the selected source base (e.g., only 0–7 for octal).
Frequently asked questions
What bases are supported?
Binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16) — the four bases most commonly used in computing.
How do I convert binary to hexadecimal?
Group binary digits in sets of 4 from the right and convert each group to its hex digit. Binary 1111 = F, 0100 = 4, so 11110100 = F4. Or use this calculator directly.
What is octal used for?
Octal (base 8) was used in early computing and is still used in Unix/Linux file permissions. chmod 755 means owner=7 (rwx), group=5 (r-x), others=5 (r-x) in octal.
Why do programmers use hexadecimal?
Each hex digit maps to exactly 4 binary bits, making hex a compact and readable shorthand for binary. A byte (8 bits) is always two hex digits, which is why memory addresses and colors use hex.
What happens if I enter an invalid digit?
The calculator returns an invalid result. Make sure your input only contains valid digits for the source base — for binary only 0 and 1, for octal 0–7, for hex 0–9 and A–F.
Last updated: 2025-01-15 · Formula verified against primary sources.