Number Base Converter
Convert between numeric bases
Number bases are different ways to represent the same value. Decimal (base 10) is for humans, binary (base 2) is for computers, hexadecimal (base 16) bridges both worlds.
What are Number Bases?
A number base (or radix) defines how many unique digits are used to represent numbers in a positional numeral system. In everyday life, we use base 10 (decimal) with digits 0 through 9. Computers operate in base 2 (binary) with just 0 and 1. Programmers frequently use base 16 (hexadecimal) with digits 0-9 and letters A-F as a compact way to represent binary data.
The key insight is that all these bases represent the same underlying values — just written differently. The decimal number 42 is 101010 in binary, 2A in hexadecimal, and 52 in octal. The number itself does not change; only its representation does.
In a positional system, each digit’s value depends on its position. In decimal, the number 255 means (2 x 10^2) + (5 x 10^1) + (5 x 10^0) = 200 + 50 + 5. In binary, 11111111 means (1 x 2^7) + (1 x 2^6) + … + (1 x 2^0) = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255. The same principle applies to any base.
Binary, Octal, and Hexadecimal
Binary (Base 2)
Binary is the native language of digital electronics. Every processor, every memory chip, every network packet operates on binary data — sequences of 0s and 1s. Each binary digit is called a bit, and 8 bits form a byte.
| Decimal | Binary | Bits |
|---|---|---|
| 0 | 0 | 1 bit |
| 1 | 1 | 1 bit |
| 10 | 1010 | 4 bits |
| 42 | 101010 | 6 bits |
| 127 | 1111111 | 7 bits |
| 255 | 11111111 | 8 bits (1 byte) |
Binary is fundamental but impractical for humans to read in bulk. A 32-bit IP address in binary is 11000000101010000000000100000001 — compared to its decimal form 192.168.1.1 or hex form C0A80101.
Octal (Base 8)
Octal uses digits 0-7. Each octal digit corresponds to exactly 3 binary bits, making conversion between binary and octal straightforward. Octal was more common in early computing (PDP-8, Unix), and its most visible legacy today is Unix file permissions.
| Octal | Binary | Permission |
|---|---|---|
| 0 | 000 | --- (none) |
| 1 | 001 | --x (execute) |
| 4 | 100 | r-- (read) |
| 5 | 101 | r-x (read + execute) |
| 6 | 110 | rw- (read + write) |
| 7 | 111 | rwx (all) |
So chmod 644 means: owner = rw- (6), group = r— (4), others = r— (4).
Hexadecimal (Base 16)
Hexadecimal (hex) uses digits 0-9 and letters A-F (where A=10, B=11, …, F=15). Each hex digit represents exactly 4 binary bits (a nibble), and two hex digits represent exactly 1 byte. This 1:1 mapping between hex digits and nibbles is why hex is the universal format for representing binary data in a human-readable way.
| Decimal | Hex | Binary |
|---|---|---|
| 0 | 0 | 0000 |
| 9 | 9 | 1001 |
| 10 | A | 1010 |
| 15 | F | 1111 |
| 255 | FF | 11111111 |
| 256 | 100 | 100000000 |
Hex values are typically prefixed to distinguish them from decimal: 0xFF (C/JavaScript), #FF5733 (CSS colors), U+00E9 (Unicode code points), or simply written with a trailing h in assembly language.
Practical Uses
Number bases appear throughout software development and system administration:
- CSS colors: The hex color
#FF5733breaks down as Red=FF (255), Green=57 (87), Blue=33 (51). Each pair of hex digits represents one byte of color intensity, ranging from 00 (0) to FF (255) - Memory addresses and debugging: Debuggers and hex editors display memory as hexadecimal because each byte is neatly represented by two digits. A 64-bit memory address like
0x7FFF5FBFF8A0is far more readable than its binary equivalent - Network configuration: IPv4 addresses are decimal (192.168.1.1), but subnet masks are clearer in binary (255.255.255.0 = 11111111.11111111.11111111.00000000). MAC addresses use hex (00:1A:2B:3C:4D:5E). IPv6 addresses are entirely hexadecimal
- Unicode code points: Characters are identified by hex code points (U+0041 = “A”, U+00E9 = “e with accent”, U+1F600 = grinning face emoji)
- File signatures (magic bytes): File formats are identified by their first bytes in hex. A PNG file starts with
89 50 4E 47, a PDF with25 50 44 46(which is%PDFin ASCII) - Bitwise operations and flags: Feature flags, permission bitmasks, and hardware registers are expressed in hex or binary because each bit has an individual meaning. For example, a TCP flags byte of
0x12=00010010= SYN+ACK
Common Use Cases
- Color conversion: Web developers regularly convert between hex color codes (#RGB), decimal RGB values (rgb(255, 87, 51)), and HSL representations. Understanding hex makes color manipulation intuitive
- Debugging binary protocols: Network packet analysis (Wireshark), firmware analysis, and reverse engineering all require reading hexadecimal data. Converting between hex, binary, and decimal is an essential skill
- File permission management: System administrators use octal notation daily for
chmodcommands. Understanding that 755 = rwxr-xr-x requires knowing octal-to-binary conversion - Bitflag manipulation: Combining flags with OR (
0x01 | 0x04 = 0x05), checking flags with AND (value & 0x04), and toggling with XOR all require comfort with binary and hexadecimal - Data encoding inspection: When debugging Base64, URL encoding, or character encoding issues, examining the raw byte values in hex is often the fastest path to understanding the problem
Try These Examples
Decimal 255 = hexadecimal FF = binary 11111111 = octal 377. This value is significant because it represents the maximum value of a single unsigned byte (8 bits), commonly seen in RGB color values and subnet masks.
255 The string 'XYZ' is not a valid number in any standard base (up to base 36). While X, Y, and Z are valid digits in bases 34-36 respectively, the input must specify which base is intended for parsing.
XYZ