How to Convert Between Binary, Octal, Decimal, and Hex
Number base conversion is fundamental to computing. Computers operate in binary (base-2), file permissions use octal (base-8), humans think in decimal (base-10), and colors and memory addresses use hexadecimal (base-16). Converting between these bases is a core skill for developers.
- Convert numbers between binary (base-2), octal (base-8), decimal (base-10), and hexadecimal (base-16).
- Covers understanding number bases.
- Covers binary โ decimal.
- Covers hexadecimal conversions.
- Covers converting in javascript.
Understanding Number Bases
A number base defines how many digits are available. Decimal uses 0-9 (10 digits). Binary uses 0-1 (2 digits). Octal uses 0-7 (8 digits). Hexadecimal uses 0-9 and A-F (16 digits). The number 255 in decimal equals 11111111 in binary, 377 in octal, and FF in hexadecimal โ they all represent the same quantity.
Binary โ Decimal
To convert binary to decimal, multiply each digit by its positional power of 2 and sum: 1101 = (1ร8) + (1ร4) + (0ร2) + (1ร1) = 13. To convert decimal to binary, repeatedly divide by 2 and read remainders bottom-to-top: 13 รท 2 = 6 remainder 1, 6 รท 2 = 3 remainder 0, 3 รท 2 = 1 remainder 1, 1 รท 2 = 0 remainder 1. Result: 1101.
Hexadecimal Conversions
Hex is the most practical base for developers โ it maps cleanly to binary (each hex digit = 4 binary digits) and is used for colors (#FF6B6B), memory addresses, and byte values. F = 1111 in binary = 15 in decimal. FF = 11111111 = 255. A0 = 10100000 = 160. The Number Base Converter handles all conversions instantly โ enter any value in any base and see all other bases.
background-size animation or @property registered custom properties instead.Converting in JavaScript
parseInt('FF', 16) converts hex to decimal (255). parseInt('11111111', 2) converts binary to decimal (255). (255).toString(16) converts decimal to hex ('ff'). (255).toString(2) converts decimal to binary ('11111111'). The second argument specifies the base (radix).
Frequently Asked Questions
How do I convert binary to decimal?
Why do programmers use hexadecimal?
What is octal used for?
Use the Number Base Converter โ free, no signup required.
โก Open Number Base Converter