number base converterbinaryhexadecimaloctalnumber systemsprogramming

Number Systems: Binary, Octal, Decimal, and Hexadecimal Explained

Computers use different number bases for different purposes. Learn what binary, octal, decimal, and hexadecimal are, why they exist, and how to convert between them.

9 min read

Related Tool

Number Base Converter

Open tool

A number base (or radix) defines how many distinct symbols are used to represent numbers. The decimal system we use daily has base 10 and uses ten symbols (0 through 9). Computers work in base 2 (binary) internally but programmers often use base 16 (hexadecimal) as a compact representation. Understanding number bases is fundamental to programming, debugging, and working with computer systems.

Decimal (Base 10)

Decimal is the system humans naturally use. It has 10 digits (0 through 9). Each position represents a power of 10: the units position, the tens position, the hundreds position, and so on. The number 429 means 4 hundreds plus 2 tens plus 9 ones.

Binary (Base 2)

Binary has 2 digits: 0 and 1. Computers use binary because electronic circuits are most naturally built as two-state systems (on or off, high voltage or low voltage). Each binary digit is called a bit. Eight bits form a byte.

Each position in a binary number represents a power of 2. The rightmost position is 2 to the power 0 (1). Moving left: 2, 4, 8, 16, 32, 64, 128. The binary number 1010 means 8 plus 0 plus 2 plus 0, which equals 10 in decimal.

Binary appears in bitwise operations (AND, OR, XOR, NOT, bit shifts), in file permission notation, in network subnet masks, and in data structure optimization.

Octal (Base 8)

Octal has 8 digits (0 through 7). Each position represents a power of 8. Octal is convenient because each octal digit represents exactly 3 bits, and three octal digits represent a full byte. Unix file permissions use octal: the permission 755 in octal means 111 101 101 in binary, which represents read-write-execute for owner, read-execute for group, read-execute for others.

Hexadecimal (Base 16)

Hexadecimal has 16 symbols: 0 through 9 and A through F (where A is 10, B is 11, C is 12, D is 13, E is 14, and F is 15). Each hexadecimal digit represents exactly 4 bits. Two hex digits represent one byte.

Hexadecimal is the preferred compact notation for binary data in programming. Memory addresses are written in hex (0x00007FFE4A2B1000). Colors in CSS are written in hex (#FF5733). Cryptographic hashes are displayed in hex. Binary data in protocols and file formats is documented in hex.

Using the DevHexLab Number Base Converter

Open the tool at /tools/converters/number-base-converter. Enter a number and select its base. The equivalent in all other bases appears simultaneously. Copy any result you need.

Frequently Asked Questions

Why do programmers prefix hexadecimal with 0x?

The 0x prefix (for example, 0xFF) tells the compiler or parser that the following number is in hexadecimal rather than decimal. Without the prefix, FF would be interpreted as a variable name.

What does base 64 have to do with the other bases?

Base 64 (as in Base64 encoding) is a text encoding scheme that uses 64 characters to represent arbitrary binary data. It is not a number base in the same sense as binary, octal, decimal, and hexadecimal.

Understand number bases and low-level programming becomes significantly less mysterious.