Number Base Converter β Binary, Octal, Decimal & Hex Explained
Learn how binary, octal, decimal, and hexadecimal number systems work, when each is used in programming, and how to convert between them instantly with a free number base converter.
By sadiqbd Β· June 6, 2026
Numbers look completely different depending on which base you use
Binary, octal, decimal, hexadecimal β the same value can be written four different ways, and none of them look alike. The decimal number 255 is 11111111 in binary, 377 in octal, and FF in hexadecimal. If you're working in low-level programming, embedded systems, networking, colour codes, or computer science in general, you'll jump between these bases constantly.
Converting manually is error-prone and tedious, especially for larger numbers. A number base converter handles any conversion between bases 2, 8, 10, and 16 instantly β and some tools support arbitrary bases beyond these four.
The Four Common Number Bases
Base 10 β Decimal
The system we use for everyday counting. Digits: 0β9. Every position is a power of 10.
255 = 2Γ10Β² + 5Γ10ΒΉ + 5Γ10β° = 200 + 50 + 5
Base 2 β Binary
Only two digits: 0 and 1. Every position is a power of 2. Used by all digital computers at the hardware level β every bit in memory, every CPU instruction, every network packet is ultimately binary.
255 in binary = 11111111 (eight 1s = 128+64+32+16+8+4+2+1)
Base 8 β Octal
Digits: 0β7. Each octal digit represents exactly 3 binary bits. Was more common in older computing systems; still used in Unix/Linux file permissions.
255 in octal = 377 (3Γ64 + 7Γ8 + 7Γ1)
Base 16 β Hexadecimal (Hex)
Digits: 0β9 and AβF (where A=10, B=11, C=12, D=13, E=14, F=15). Each hex digit represents exactly 4 binary bits (a nibble). Hex is the most compact human-readable way to represent binary data.
255 in hex = FF (15Γ16 + 15Γ1)
How to Use the Number Base Converter on sadiqbd.com
- Enter the number β in any base.
- Select the source base β binary (2), octal (8), decimal (10), or hexadecimal (16).
- Read the conversions β the tool shows the equivalent in all other bases simultaneously.
Most base converters also handle hexadecimal input case-insensitively (both ff and FF work) and support the 0x prefix notation common in code.
Real-World Examples
Web colours in hex
CSS and HTML colour codes are hexadecimal. #FF5733 breaks down as:
- R:
FF= 255 decimal - G:
57= 87 decimal - B:
33= 51 decimal
Converting #1A9BE6:
- R:
1Ahex = 1Γ16 + 10 = 26 - G:
9Bhex = 9Γ16 + 11 = 155 - B:
E6hex = 14Γ16 + 6 = 230
This is the conversion needed when an API accepts colour as RGB integers but your designer provided a hex code.
Unix file permissions
The permission string rwxr-xr-- in octal is 754:
- Owner: rwx = 4+2+1 = 7
- Group: r-x = 4+0+1 = 5
- Others: r-- = 4+0+0 = 4
chmod 755 sets owner full permissions, group and others read+execute. In binary:
755 octal = 111 101 101 binary β each group of 3 bits maps directly to rwx for each permission class.
Network subnet masks
The subnet mask 255.255.255.0 in binary is:
11111111.11111111.11111111.00000000
255.255.240.0:
255=11111111240=11110000
The transition from 1s to 0s marks the network/host boundary β a /20 subnet in CIDR notation. Network engineers work in binary regularly; the converter makes translating from dotted-decimal immediate.
Embedded systems and registers
A microcontroller register has value 0x4A. What bits are set?
0x4A hex = 74 decimal = 01001010 binary
Bits 1, 3, and 6 are set (counting from 0 on the right). Knowing which bits are set tells you which hardware features are enabled. This kind of binary inspection is daily work in embedded development.
ASCII and character codes
The ASCII code for A is 65 decimal:
- Binary:
01000001 - Hex:
41 - Octal:
101
Hex representation is most commonly used in memory dumps and protocol specifications β you'll see 0x41 in packet captures and debug output far more than decimal 65.
Why Hex Is So Prevalent in Programming
Hexadecimal is the preferred representation for raw binary data because of its density and its clean mapping to binary:
- 4 bits per hex digit: one hex digit perfectly encodes one nibble. Two hex digits encode one byte.
0xFF= 8 bits all set to 1. - More compact than binary:
FFis easier to read and write than11111111, especially for 32-bit or 64-bit values. - Direct mapping: converting between hex and binary is mechanical β each hex digit maps to exactly 4 binary bits, no arithmetic needed.
This is why memory addresses (0x7FFF5FBF0000), colour codes (#3A86FF), cryptographic hashes (a3b4c5d6...), and MAC addresses (AA:BB:CC:DD:EE:FF) are all written in hex.
Tips for Working With Number Bases
Memorise the hex-binary table for single digits. 0=0000, 1=0001, 2=0010, 3=0011, 4=0100, 5=0101, 6=0110, 7=0111, 8=1000, 9=1001, A=1010, B=1011, C=1100, D=1101, E=1110, F=1111. Once this is automatic, binaryβhex conversion requires no arithmetic.
Use the 0x prefix for hex in code. Most programming languages (C, Python, JavaScript, Java) use 0x to denote hexadecimal literals: 0xFF, 0x1A3F. This prevents ambiguity β FF alone could be a variable name; 0xFF is unambiguously hex.
Powers of 2 are your anchor points. 2βΈ=256, 2ΒΉβ°=1024, 2ΒΉβΆ=65536, 2Β³Β²=4,294,967,296. Knowing these makes quick sanity checks easy.
Octal shows up mostly in Unix permissions. Outside of that context, you'll rarely use base 8. If you see a number prefixed with 0 in C code (like 0755), that's octal β a subtle gotcha when porting code.
Frequently Asked Questions
What's the easiest way to convert binary to hexadecimal?
Group the binary digits into sets of 4 from the right, then convert each group to its hex digit. 10111010 β 1011 1010 β B A β 0xBA. No arithmetic required.
Why do computers use binary? Electronic circuits have two stable states: on and off, high voltage and low voltage. Binary maps perfectly to this β 1 is on, 0 is off. Every bit in memory, every transistor in a CPU, is fundamentally a binary switch.
What does 0x mean before a number?
It's a prefix indicating hexadecimal notation, used in most programming languages. 0xFF = 255 decimal. The 0x itself has no numeric value β it's just a notation convention.
Can I convert to bases other than 2, 8, 10, 16? Some converters support arbitrary bases (base 3, base 5, base 32, etc.). Base 64 is used in data encoding (though Base64 encoding is a slightly different concept). For most programming purposes, bases 2, 8, 10, and 16 cover everything.
Is the number base converter free? Yes β completely free, no sign-up required.
Base conversion is one of those skills that's genuinely mechanical β it's just arithmetic β but doing it by hand for anything beyond trivial values is slow and error-prone. The converter makes it instant so you can stay focused on the actual problem you're solving.
Try the Number Base Converter free at sadiqbd.com β instant conversion between binary, octal, decimal, and hexadecimal.