The Ultimate Guide to Numeral Systems, Binary Code, and Hexadecimal
A thorough, beginner-friendly reference for computer science students, developers, and curious minds.
Every numeral system is defined by its base (also called the radix) - the total count of unique digit symbols it uses. The base you are probably most familiar with is Base-10 (Decimal), which uses the ten symbols 0 through 9. This system developed historically because humans have ten fingers, making it a natural choice for everyday counting.
Base-2 (Binary) uses only two symbols: 0 and 1. Each symbol is called a bit (binary digit). Computers are built from billions of tiny transistors that are either off (0) or on (1), which is why binary is the native language of all digital hardware.
Base-8 (Octal) uses the digits 0 through 7. It was historically used in early computing because one octal digit maps neatly to exactly three binary bits, making it a compact shorthand for binary notation.
Base-16 (Hexadecimal) uses sixteen symbols: the digits 0 through 9 plus the letters A through F (where A = 10, B = 11, ..., F = 15). One hex digit represents exactly four binary bits (called a nibble), so hex is extremely popular as a compact, human-readable representation of binary data in programming, memory addresses, and colors.
The core reason is physical reliability. A transistor - the fundamental building block of a computer processor - operates most reliably in two distinct electrical states: a high voltage (representing 1) and a low voltage (representing 0). Engineering a circuit that reliably distinguishes ten different voltage levels (as decimal would require) is vastly more complex, more expensive, and far more prone to error than one that only needs to tell apart two levels.
Beyond hardware, binary also maps perfectly onto Boolean algebra, the mathematics of logic (true/false, AND, OR, NOT). This allows computers to perform both arithmetic and logical decision-making using the same underlying circuits, creating a beautifully unified system.
A single binary digit (bit) is the smallest possible unit of information. Eight bits grouped together form a byte, which can represent 256 unique values ($ 2^8 = 256 $). Modern computers process billions of these bytes every second to render text, images, video, and everything else on your screen.
Each position in a binary number represents a power of 2, starting from $ 2^0 = 1 $ on the right and increasing by one power for each position you move left. To convert a binary number to decimal, multiply each bit by its positional power of 2 and add the results.
Example: Convert the binary number $ 1011_2 $ to decimal.
So the binary number $ 1011_2 $ equals 11 in decimal. The subscript notation ($ _2 $, $ _{10} $) indicates the base of each number, preventing ambiguity when working across multiple systems.
The general formula for any number in base $ b $ with digits $ d_n, d_{n-1}, ..., d_1, d_0 $ is:
Web Colors (RGB Hex Codes): Computer screens mix three color channels - Red, Green, and Blue (RGB) - each with an intensity from 0 to 255. Since $ 255 = FF_{16} $, each channel can be perfectly represented by exactly two hex digits. A full RGB color therefore fits in six hex digits, which is why you see HTML color codes like #A3F5C1. Breaking that down: A3 = red intensity, F5 = green intensity, C1 = blue intensity. Hex is used here because it is far more compact than writing out three decimal numbers, and one color fits in a single short string.
MAC Addresses (Media Access Control): Every network interface card (Wi-Fi or Ethernet adapter) is assigned a globally unique 48-bit identifier called a MAC address. Because 48 bits would be unwieldy to write in binary, MAC addresses are displayed as six pairs of hex digits separated by colons or hyphens, for example: 3C:22:FB:A0:1D:77. Each pair represents 8 bits (one byte), giving the address a total length of 6 bytes (48 bits).
Memory Addresses: In systems programming and debugging tools, memory locations are almost always shown in hexadecimal because it provides a compact yet direct mapping to the binary values stored in hardware registers.
ASCII stands for the American Standard Code for Information Interchange. It is a character encoding standard that was established in 1963 and assigns a unique integer (called a code point) to each printable character in the English alphabet, the digits 0 through 9, common punctuation marks, and a set of control codes.
For example, the uppercase letter A is assigned the decimal value 65, which in binary is 01000001 and in hexadecimal is 41. The word "Hello" is therefore stored in memory as the byte sequence 72 101 108 108 111 in decimal, or 48 65 6C 6C 6F in hex.
Because ASCII only uses 7 bits, it covers exactly 128 characters ($ 2^7 = 128 $). Modern systems commonly use UTF-8, a superset of ASCII that extends to cover over 1 million Unicode characters (including emoji, Chinese, Arabic, and virtually all writing systems) while remaining fully backwards-compatible with ASCII for the first 128 code points.
The Mode 2 ASCII Translator above uses standard ASCII/UTF-8 code points when encoding your text. When you toggle "Code to Text," it reads the binary, hex, or octal groups, converts each back to its code point, and then uses that code point to recover the original character.
Conversion Cheat Sheet: Decimal 0 to 15
This table shows the four representations for the first sixteen non-negative integers - the range covered by a single hexadecimal digit or a four-bit binary nibble.
| Decimal (Base-10) | Binary (Base-2) | Octal (Base-8) | Hexadecimal (Base-16) |
|---|
Bits, Bytes, and Why Size Matters
A single bit (binary digit) can hold only two values: 0 or 1. Grouping eight bits together creates a byte, which can represent $ 2^8 = 256 $ distinct values (0 through 255). The byte is the basic unit of digital storage, and almost all file sizes, memory capacities, and data transfer rates are expressed in multiples of bytes (kilobytes, megabytes, gigabytes, and so on).
A nibble is four bits - exactly half a byte. Because $ 2^4 = 16 $, one nibble maps perfectly to a single hexadecimal digit, which is why hex is such a natural notation for raw binary data: each byte can always be written as exactly two hex digits with no waste or ambiguity.
Practical Tips for Developers
When reading color values in CSS, design tools, or image editors, you will encounter six-digit hex codes prefixed with #. You can split these into three two-digit pairs to read the red, green, and blue channels independently. A value of #FF0000 is pure red (red = 255, green = 0, blue = 0), while #FFFFFF is white (all channels at maximum) and #000000 is black (all channels at zero).
In Python, the built-in functions bin(), oct(), and hex() convert a decimal integer to its binary, octal, or hex string representation. In JavaScript, Number.toString(base) does the same for any base between 2 and 36. Conversely, parseInt(string, base) parses a string in a given base back to a decimal integer - exactly the same logic this tool uses under the hood.