# Number Base Converter

URL: https://hifreetools.com/developer/number-base-converter

> Instantly convert any integer between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16) — all four results update live as you type.

## Quick answer

To convert between number bases, enter a value in any base and the tool automatically converts it to all other bases. Binary uses digits 0–1, octal uses 0–7, decimal uses 0–9, and hexadecimal uses 0–9 and A–F. For example, decimal 255 equals binary 11111111, octal 377, and hexadecimal FF. Conversion works by first expressing the number as a sum of powers of its source base, then re-expressing that value in the target base.

## Formula

- N₁₀ = d₍ₙ₎ × b^n + … + d₁ × b¹ + d₀ × b⁰

## Examples

- Decimal 255 → Binary / Octal / Hex: 255 (decimal, base 10) → Binary: 11111111 | Octal: 377 | Hex: FF
- Binary 1010 → Decimal / Octal / Hex: 1010 (binary, base 2) → Decimal: 10 | Octal: 12 | Hex: A
- Hexadecimal FF → Decimal / Binary / Octal: FF (hexadecimal, base 16) → Decimal: 255 | Binary: 11111111 | Octal: 377
- Octal 777 → Decimal / Binary / Hex: 777 (octal, base 8) → Decimal: 511 | Binary: 111111111 | Hex: 1FF

## FAQ

**Why do programmers use hexadecimal instead of binary?**
Hexadecimal is far more compact than binary — every 4 binary digits collapse into one hex digit. A 32-bit value takes 32 characters in binary but only 8 in hex, making memory addresses, color codes, and bytecodes much easier to read and type.

**What is the difference between base 2, base 8, base 10, and base 16?**
Base 2 (binary) uses only 0 and 1 and maps directly to transistor on/off states. Base 8 (octal) uses digits 0–7 and groups binary bits in threes. Base 10 (decimal) is the everyday counting system using 0–9. Base 16 (hexadecimal) uses 0–9 plus A–F and groups binary bits in fours.

**How do I convert a hex letter like A, B, C to a number?**
The hex digits A through F represent the decimal values 10 through 15 respectively. A=10, B=11, C=12, D=13, E=14, F=15. When converting, substitute these values before performing the positional multiplication.

**Can this converter handle large numbers?**
The converter uses JavaScript's built-in parseInt and toString methods, which support safe integers up to 2^53−1 (about 9 quadrillion in decimal). For most programming tasks — addresses, color codes, flags — this is more than sufficient.

**Why does octal start with 0 in C (and 0o in Python)?**
In C and many C-descended languages, a leading zero (0755) signals octal to the compiler; Python 3 uses the explicit 0o prefix (0o755) instead. Octal was popular in early Unix, where file permissions (e.g. chmod 755) are written in octal.

**What are common real-world uses of number base conversion?**
Hexadecimal is used for HTML/CSS color codes (#FF5733), memory addresses, and machine opcodes. Binary appears in bitmasking, flags, and network subnet masks. Octal is still used for Unix file permissions (chmod 755 = rwxr-xr-x). Understanding all four bases is essential for low-level programming and computer science.


## Sources

- [MDN Web Docs — parseInt()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt)
- [Wikipedia — Positional notation](https://en.wikipedia.org/wiki/Positional_notation)
- [Wikipedia — Hexadecimal](https://en.wikipedia.org/wiki/Hexadecimal)

Runs in the browser; nothing is uploaded. Cite as: HIFreeTools, "Number Base Converter", https://hifreetools.com/developer/number-base-converter
