Number Base Converter — Binary, Octal, Decimal, Hex

Binary (Base 2)

0

Octal (Base 8)

0

Decimal (Base 10)

0

Hexadecimal (Base 16)

0

How Number Base Systems Work

A number base (also called a radix) is a numeral system that defines how many unique digit symbols are used to represent numbers. The decimal system (base 10) that humans use daily employs digits 0 through 9, while computers natively operate in binary (base 2) using only 0 and 1. According to Encyclopaedia Britannica, positional numeral systems were first developed by the Babylonians using base 60 around 3000 BCE, and the base-10 system we use today originated in India around the 6th century CE.

In any positional number system, each digit's value depends on its position. The rightmost digit represents units (base^0), the next represents the base value (base^1), then base^2, and so on. This converter handles the four most commonly used bases in computing: binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16). As noted by the IEEE Computer Society, hexadecimal became the dominant shorthand for binary data because each hex digit maps perfectly to 4 bits, making conversions between hex and binary trivially simple. Understanding these number systems is foundational for computer science, networking, and digital electronics.

How Number Base Conversion Is Calculated

Converting between number bases involves two steps: first expand the source number into decimal, then convert from decimal to the target base.

Step 1 -- Source to Decimal: Multiply each digit by base^position (position 0 is rightmost) and sum all products. Formula: value = d(n) x b^n + d(n-1) x b^(n-1) + ... + d(1) x b^1 + d(0) x b^0.

Step 2 -- Decimal to Target: Repeatedly divide the decimal value by the target base. Record each remainder. Read remainders from bottom to top to form the result.

Worked example -- Convert binary 10110 to hexadecimal: First, binary to decimal: (1x16) + (0x8) + (1x4) + (1x2) + (0x1) = 22. Then decimal 22 to hex: 22 / 16 = 1 remainder 6, then 1 / 16 = 0 remainder 1. Reading bottom to top: 16 (hex). Alternatively, group binary digits into sets of 4 from the right: 0001 0110. 0001 = 1, 0110 = 6, giving 16 (hex). This grouping shortcut works because 16 = 2^4.

Key Terms You Should Know

Bit: A single binary digit (0 or 1). It is the smallest unit of data in computing. The term was coined by Claude Shannon in 1948 in his landmark paper on information theory.

Byte: A group of 8 bits, capable of representing 256 (2^8) distinct values from 0 to 255. One byte can store a single ASCII character or a value from 00 to FF in hexadecimal.

Radix: The number of unique digits in a positional numeral system. Binary has radix 2, octal has radix 8, decimal has radix 10, and hexadecimal has radix 16.

Nibble: A group of 4 bits, represented by a single hexadecimal digit. Two nibbles make one byte. This term is commonly used in low-level programming and hardware documentation.

Most Significant Bit (MSB): The leftmost bit in a binary number, carrying the highest positional value. In an 8-bit byte, the MSB represents 2^7 = 128.

Number Base Comparison Reference

The table below shows the same values represented across all four common number bases, demonstrating the relationship between systems. These values are particularly important in computing and networking.

DecimalBinaryOctalHexadecimalCommon Use
0000000Null / false
10101012AHex digit start of letters
1270111 11111777FMax signed 8-bit integer
2551111 1111377FFMax unsigned byte / max RGB channel
75510 1111 001113632F3Unix permission (rwxr-xr-x)
1024100 0000 000020004001 KB (kibibyte)
655351111 1111 1111 1111177777FFFFMax unsigned 16-bit integer
1677721524 bits all 1s77777777FFFFFFWhite in RGB color (#FFFFFF)

Practical Examples

Example 1 -- CSS color conversion: The CSS color #3A8FD4 needs to be understood in RGB decimal. Split into pairs: 3A, 8F, D4. Convert each hex pair: 3A = 3x16 + 10 = 58 (red), 8F = 8x16 + 15 = 143 (green), D4 = 13x16 + 4 = 212 (blue). So rgb(58, 143, 212) is the decimal equivalent. Use our scientific notation calculator for large number conversions.

Example 2 -- Unix file permissions: You want to set permissions to rwxr-xr-- (owner: read+write+execute, group: read+execute, others: read-only). In binary: 111 101 100. Convert each 3-bit group to octal: 111 = 7, 101 = 5, 100 = 4. The chmod command is chmod 754. You can verify with our combinations calculator that there are 8 possible permission states per user class.

Example 3 -- Network subnet mask: A /24 subnet mask in binary is 11111111.11111111.11111111.00000000. Converting each octet to decimal: 255.255.255.0. In hex, each FF pair represents the 255 octets, giving the mask FF.FF.FF.00. Understanding this binary-to-decimal conversion is essential for networking and IP address management.

Tips and Strategies for Base Conversion

Frequently Asked Questions

How do I convert binary to decimal?

To convert binary to decimal, multiply each digit by 2 raised to the power of its position, counting from 0 on the right, then sum all the products. For example, binary 1011 has four digits. From right to left: (1 x 2^0) + (1 x 2^1) + (0 x 2^2) + (1 x 2^3) = 1 + 2 + 0 + 8 = 11 in decimal. For larger binary numbers, the same process applies. Binary 11111111 converts to 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255 in decimal, which is the maximum value of a single byte.

Why do computers use binary?

Computers use binary because digital electronic circuits operate using two stable voltage states: high (representing 1) and low (representing 0). This two-state system is inherently reliable because the circuit only needs to distinguish between two levels rather than ten. Claude Shannon demonstrated in his 1937 master's thesis that Boolean algebra could be implemented with electronic switches, laying the theoretical foundation for all modern digital computing. Every piece of data in a computer, from text to images to video, is ultimately encoded as sequences of binary digits called bits.

What is hexadecimal used for in programming?

Hexadecimal (base 16) provides a human-readable shorthand for binary data because each hex digit maps to exactly 4 binary digits. This makes it far more compact than writing long binary strings. Common uses include CSS and HTML color codes where #FF0000 represents red (255 red, 0 green, 0 blue), memory addresses in debugging and systems programming, MAC addresses for network devices written as six pairs of hex digits, and Unicode character codes. A single byte (8 bits) can be represented by exactly two hex digits ranging from 00 to FF, which is much easier to read than the binary range 00000000 to 11111111.

How do I convert decimal to hexadecimal?

To convert decimal to hexadecimal, repeatedly divide the number by 16 and record each remainder. Then read the remainders from bottom to top to form the hex number. For remainders 10 through 15, use the letters A through F. For example, to convert 255: 255 divided by 16 equals 15 remainder 15, then 15 divided by 16 equals 0 remainder 15. Since 15 is represented as F in hexadecimal, reading bottom to top gives FF. Another example: 200 divided by 16 equals 12 remainder 8, then 12 divided by 16 equals 0 remainder 12 (which is C). So 200 decimal equals C8 hexadecimal.

What is octal and where is it still used?

Octal is the base-8 number system using digits 0 through 7, where each octal digit represents exactly 3 binary digits. Octal was historically popular in early computing systems that used 12-bit, 24-bit, or 36-bit word sizes because these divide evenly by 3. Today, octal is most commonly used in Unix and Linux file permissions. The chmod command uses three octal digits to set read (4), write (2), and execute (1) permissions for owner, group, and others. For example, chmod 755 grants the owner full access (7 = 4+2+1) while giving group and others read and execute access (5 = 4+0+1).

What is the largest number that can be stored in different bit sizes?

The maximum unsigned integer value for a given bit size is calculated as 2^n minus 1, where n is the number of bits. An 8-bit byte stores values from 0 to 255. A 16-bit integer stores up to 65,535. A 32-bit integer stores up to 4,294,967,295 (about 4.3 billion). A 64-bit integer stores up to 18,446,744,073,709,551,615 (about 18.4 quintillion). If one bit is used for the sign (positive or negative), the range is halved. A signed 32-bit integer ranges from negative 2,147,483,648 to positive 2,147,483,647, which is the limit for the classic int data type in languages like C and Java.

Related Calculators