Number bases, explained
Computers store data in bits, people usually count in decimal, and developers constantly meet hexadecimal in between. That is why the same value can appear as 65, 0b01000001, 0x41, or the character A.
Those are not four different values. They are four different ways to write or interpret related data.
Once you understand positional notation, number bases stop feeling like separate tricks. Binary, decimal, and hexadecimal all use the same idea: a digit's position tells you its weight. ASCII then adds one more layer by mapping numbers to characters.
This guide explains binary, decimal, hexadecimal, bytes, ASCII, and the developer workflows where converting between them is actually useful.
Positional notation
Decimal feels natural because we use it every day, but it is still a positional system.
Take the number:
472
Read by position, that means:
4 x 100 + 7 x 10 + 2 x 1
Or:
4 x 10^2 + 7 x 10^1 + 2 x 10^0
The base is 10, so each place is a power of 10.
Other bases work the same way. The base changes. The position rule stays.
Binary
Binary is base 2. It uses two digits:
0 and 1
Each position is a power of 2.
This binary value:
1011
means:
1 x 8 + 0 x 4 + 1 x 2 + 1 x 1 = 11
So binary 1011 is decimal 11.
Binary maps directly to bits, which is why it matters in computing. Flags, masks, permissions, machine instructions, and raw file data all come back to bits at some level.
The downside is length. Even small decimal numbers can take many binary digits, which makes binary hard to read in long chunks.
Decimal
Decimal is base 10. It uses ten digits:
0 1 2 3 4 5 6 7 8 9
It is the default for most human-facing numbers: counts, prices, measurements, dates, and ordinary UI values.
Developers still need decimal because it is what users expect to see. A byte value may be stored as bits and written as hex in docs, but a form field asking for age, quantity, or timeout seconds will usually display decimal.
Hexadecimal
Hexadecimal is base 16. It uses sixteen digit symbols:
0 1 2 3 4 5 6 7 8 9 A B C D E F
The letters represent values 10 through 15.
Hex is popular because it lines up neatly with binary. One hex digit represents four bits.
Example:
F = 1111
A = 1010
0 = 0000
That makes hex a compact way to write bytes. A byte is 8 bits, so it fits in exactly two hex digits.
Example:
11111111 = FF
01000001 = 41
00000000 = 00
This is why hex shows up in color codes, binary dumps, hashes, memory addresses, Unicode code points, URL percent-encoding, and protocol docs.
Bytes
A byte is usually 8 bits. That gives it 256 possible values, from decimal 0 to 255.
In hex, that range is:
00 to FF
That two-digit hex shape is everywhere because bytes are a natural unit for files, network data, encodings, and memory.
If you see a string like this:
48 65 6c 6c 6f
it may be a sequence of byte values written in hex. What those bytes mean depends on the encoding or file format.
ASCII
ASCII maps numbers to characters.
For example:
65 decimal = 0x41 hex = A
A few more examples:
48 decimal = 0x30 hex = 0
57 decimal = 0x39 hex = 9
97 decimal = 0x61 hex = a
ASCII covers a small English-centered character set: letters, digits, punctuation, control characters, and space. Modern text usually uses Unicode, often encoded as UTF-8, but ASCII still matters because UTF-8 keeps ASCII bytes unchanged for the basic range.
That is why 48 65 6c 6c 6f as hex bytes can decode to:
Hello
Each byte maps to one ASCII character in that example.
Why developers move between bases
Base conversion is not only a classroom exercise. It appears in practical debugging and design work.
You may convert values when:
- reading binary flags from a protocol
- checking file signatures and byte dumps
- writing CSS color values
- reading hash output
- debugging URL percent-encoding
- inspecting ASCII payloads in hex
- converting permissions or bit masks
- documenting API examples
The same data can be more readable in different bases depending on the task. Binary shows individual bits. Hex shows bytes compactly. Decimal is easiest for most people. ASCII shows text meaning when bytes represent characters.
A worked example: one byte across bases
Take this binary byte:
01000001
Split it into two groups of four bits:
0100 0001
Convert each group to hex:
0100 = 4
0001 = 1
So the byte is:
0x41
Now convert 0x41 to decimal:
4 x 16 + 1 = 65
In ASCII, decimal 65 is:
A
So these all line up:
binary: 01000001
hex: 41
decimal:65
ASCII: A
That is the pattern behind a lot of byte-level work. You are not changing the stored byte. You are changing the way you write or interpret it.
A second example: color values
CSS HEX colors use three byte values: red, green, and blue.
Take:
#2563eb
Split it into pairs:
25 63 eb
Convert each hex pair to decimal:
0x25 = 37
0x63 = 99
0xeb = 235
So the RGB form is:
rgb(37 99 235)
Again, the color did not change. Only the notation changed.
Try the browser tools
These tools cover the two most common conversion jobs.
- Number Base Converter - convert values between binary, decimal, hexadecimal, and other bases when you need to check the notation.
- Hex ASCII Converter - convert byte-like hex text into ASCII or turn readable ASCII into hex bytes.
Both run in your browser, which is useful for quick debugging with copied values from logs, docs, or local test files.
Common mistakes
Confusing the value with the notation. 65, 0x41, and 01000001 can describe the same value.
Forgetting that hex digits are base 16. 10 in hex is decimal 16, not decimal 10.
Reading arbitrary hex as text. Hex bytes only become readable text when the bytes map to a text encoding such as ASCII or UTF-8.
Dropping leading zeros. For bytes, 0A and A are the same value, but the two-digit form may be important for alignment and readability.
Assuming ASCII covers every character. ASCII is small. Arabic, emoji, accented letters, and many scripts need Unicode encodings such as UTF-8.
FAQ
Binary is base 2 and writes individual bits directly. Hexadecimal is base 16 and writes each group of four bits as one digit.
Hex is much shorter and lines up cleanly with bytes. Two hex digits represent one byte.
No. Hex is a way to write numbers. ASCII is a mapping between numbers and characters.
It is a common prefix that tells readers the number is written in hexadecimal.
Yes. The same bytes might be text, image data, a hash, compressed data, or part of a protocol. Context tells you how to interpret them.
Related guides
- Base64 encoding, explained - another way binary data gets written as text.
- CSS color formats, explained - HEX color values are byte values written in base 16.
- Hashing and password storage, explained - hash digests are often shown as hexadecimal strings.