Number Systems in Digital Electronics: Binary, Decimal, Octal & Hexadecimal How engineers represent data, addresses, registers, and digital states
Series: Digital Electronics
Post: 01 / 15
Difficulty: Beginner
Reading time: 10 minutes
Prerequisites: Basic understanding of digital signals
Table of Contents
What You’ll Learn
By the end of this tutorial, you’ll understand:
- What a number system actually is
- Why digital electronics uses binary
- How to convert binary ↔ decimal
- Why engineers use hexadecimal
- Where octal is still useful
- What bits, nibbles, bytes, and words mean
- How binary addition works
- How computers represent negative numbers using two’s complement
- How number systems appear in microcontrollers, registers, memory addresses, and embedded systems
1. Why Do Digital Systems Use Different Number Systems?
If you’re beginning digital electronics, you’ll quickly encounter numbers written in several different forms:
101101₂
45₁₀
55₈
2D₁₆
At first glance, these look like completely different numbers.
They aren’t.
They can represent the same numerical value, but they use different number systems, also called bases.
A number system defines:
- Which digits are available
- How the position of each digit determines its value
For example, the decimal system uses ten digits:
0 1 2 3 4 5 6 7 8 9
Binary uses only two:
0 1
Hexadecimal uses sixteen:
0 1 2 3 4 5 6 7 8 9 A B C D E F
This leads to an important question:
Why does digital hardware rely on binary while engineers frequently write values in hexadecimal?
The answer becomes clear once we understand how positional number systems work.
2. What Is a Number System?
The base of a number system determines how many unique digits it uses and how place values increase.
In decimal, the base is 10.
Therefore, the place values are:
10⁰ 10¹ 10² 10³
1 10 100 1000
For example:
352₁₀
means:
3 × 100
+ 5 × 10
+ 2 × 1
or:
3 × 10² + 5 × 10¹ + 2 × 10⁰
Binary works the same way, but its base is 2.
Its place values are:
2⁰ 2¹ 2² 2³ 2⁴
1 2 4 8 16
So every position in a binary number represents a power of 2.
That principle is the foundation of binary representation.
3. The Four Number Systems You Need to Know
| Number System | Base | Digits | Typical Use |
|---|---|---|---|
| Binary | 2 | 0, 1 | Digital logic and bit-level data |
| Octal | 8 | 0–7 | Legacy systems, Unix/Linux permissions |
| Decimal | 10 | 0–9 | Human-readable values |
| Hexadecimal | 16 | 0–9, A–F | Registers, addresses, embedded systems |
The key idea
The base determines the place values.
Decimal → powers of 10
Binary → powers of 2
Octal → powers of 8
Hexadecimal → powers of 16
For digital electronics, binary and hexadecimal are especially important.
4. Binary: The Natural Number System of Digital Logic
Binary is a base-2 number system, meaning it has only two possible digits:
0 and 1
A single binary digit is called a bit.
Digital circuits use physical signals that are interpreted as two logical states, commonly represented as:
Logic 0 → LOW
Logic 1 → HIGH
The actual voltage corresponding to LOW and HIGH depends on the particular digital technology and device. For example, many systems use 3.3 V or 5 V logic, but the device’s datasheet should always be consulted.
Binary Place Values
Consider the binary number:
1011₂
Write the place values underneath it:
Binary: 1 0 1 1
↓ ↓ ↓ ↓
Value: 8 4 2 1
Now multiply each bit by its place value:
(1 × 8) + (0 × 4) + (1 × 2) + (1 × 1)
= 8 + 0 + 2 + 1
= 11
Therefore:
1011₂ = 11₁₀
Engineering Rule
For a binary number, each position represents a power of 2.
The place values progress as:
1 → 2 → 4 → 8 → 16 → 32 → 64 → 128 → ...
Once you understand this pattern, binary conversion becomes straightforward.
5. Converting Binary to Decimal
Binary-to-decimal conversion is one of the fundamental skills you’ll use throughout digital electronics.
Consider:
110101₂
First write the place values:
Binary: 1 1 0 1 0 1
↓ ↓ ↓ ↓ ↓ ↓
Value: 32 16 8 4 2 1
Multiply each bit by its corresponding place value:
(1 × 32)
+ (1 × 16)
+ (0 × 8)
+ (1 × 4)
+ (0 × 2)
+ (1 × 1)
Now add the results:
32 + 16 + 0 + 4 + 0 + 1 = 53
Therefore:
110101₂ = 53₁₀
Quick Method
Whenever you convert binary to decimal:
Multiply each bit by its corresponding power of 2 and add the results.
For example:
10110₂
= 1×16 + 0×8 + 1×4 + 1×2 + 0×1
= 16 + 4 + 2
= 22₁₀
6. Converting Decimal to Binary
Now let’s convert in the opposite direction.
Suppose we want to convert:
37₁₀
to binary.
The standard beginner-friendly method is repeated division by 2.
Divide the number by 2 and record the remainder each time:
| Division | Quotient | Remainder |
|---|---|---|
| 37 ÷ 2 | 18 | 1 |
| 18 ÷ 2 | 9 | 0 |
| 9 ÷ 2 | 4 | 1 |
| 4 ÷ 2 | 2 | 0 |
| 2 ÷ 2 | 1 | 0 |
| 1 ÷ 2 | 0 | 1 |
Now read the remainders from bottom to top:
1 0 0 1 0 1
Therefore:
37₁₀ = 100101₂
Why do we read from bottom to top?
Each division extracts the next binary digit starting from the least significant bit. The final division produces the most significant bit, so the remainders must be read in reverse order.
Quick Rule
For decimal → binary:
Repeatedly divide by 2, record the remainders, then read the remainders from bottom to top.
This method works for any positive decimal integer.
7. Bits, Nibbles, Bytes, and Words
As soon as you start working with microcontrollers, processors, memory, and registers, you’ll encounter terms such as:
- Bit
- Nibble
- Byte
- Word
- Double word
These terms describe groups of binary digits.
| Size | Name | Unsigned Range | Example Use |
|---|---|---|---|
| 1 bit | Bit | 0–1 | Flag, GPIO state |
| 4 bits | Nibble | 0–15 | Hexadecimal digit |
| 8 bits | Byte | 0–255 | Character, register |
| 16 bits | Word | 0–65,535 | MCU data/registers |
| 32 bits | Double word | 0–4,294,967,295 | Integer/address data |
The relationships to remember
1 nibble = 4 bits
1 byte = 8 bits
Since one hexadecimal digit represents four binary bits:
1 nibble = 1 hexadecimal digit
Therefore:
1 byte = 2 hexadecimal digits
This relationship becomes extremely useful when you’re reading microcontroller registers, debugging firmware, or interpreting hexadecimal data.
8. Hexadecimal: Binary’s Best Friend
Imagine you’re working with a 32-bit value:
11010010011110101100101011110000
It’s possible to read and write it in binary, but it’s long and easy to mistype.
Hexadecimal provides a much shorter representation.
Hexadecimal is a base-16 number system and uses:
0 1 2 3 4 5 6 7 8 9 A B C D E F
The letters represent values greater than 9:
A = 10
B = 11
C = 12
D = 13
E = 14
F = 15
The Most Important Hexadecimal Rule
One hexadecimal digit represents exactly four binary bits.
This is why hexadecimal is so useful in digital electronics.
Binary ↔ Hexadecimal Table
| Binary | Hex | Decimal |
|---|---|---|
| 0000 | 0 | 0 |
| 0001 | 1 | 1 |
| 0010 | 2 | 2 |
| 0011 | 3 | 3 |
| 0100 | 4 | 4 |
| 0101 | 5 | 5 |
| 0110 | 6 | 6 |
| 0111 | 7 | 7 |
| 1000 | 8 | 8 |
| 1001 | 9 | 9 |
| 1010 | A | 10 |
| 1011 | B | 11 |
| 1100 | C | 12 |
| 1101 | D | 13 |
| 1110 | E | 14 |
| 1111 | F | 15 |
Memorizing this table is extremely useful for anyone working with digital electronics or embedded systems.
9. Converting Binary to Hexadecimal
Binary-to-hexadecimal conversion is particularly simple.
Consider:
11010010₂
Step 1: Split the binary number into groups of four
1101 0010
Step 2: Convert each group
1101 = D
0010 = 2
Therefore:
11010010₂ = D2₁₆
In programming and embedded documentation, hexadecimal values are commonly written with the prefix:
0x
So the same value can be written as:
0xD2
Therefore:
11010010₂ = 0xD2
Another Example
Consider:
10101111₂
Split it into groups:
1010 1111
Convert each group:
1010 = A
1111 = F
Therefore:
10101111₂ = 0xAF
Quick Rule
For binary → hexadecimal:
Group the binary digits into sets of four, starting from the right, and convert each group into one hexadecimal digit.
If necessary, add leading zeros to make the number a multiple of four bits.
For example:
101101₂
becomes:
0010 1101
which gives:
0x2D
10. Why Engineers Love Hexadecimal
Hexadecimal is not replacing binary.
It is simply a compact and human-friendly representation of binary data.
The reason is the direct relationship:
1 hex digit = 4 binary bits
So:
8 bits = 2 hex digits
16 bits = 4 hex digits
32 bits = 8 hex digits
This makes hexadecimal especially useful when working with:
- Microcontroller registers
- Memory addresses
- Machine-level data
- Debugging output
- MAC addresses
- Embedded firmware
- Bit masks
- Processor data
Example: Microcontroller Register
Suppose a datasheet says:
Write 0x05 to CR1
The hexadecimal value:
0x05
is:
0000 0101₂
Looking at the individual bits:
0000 0101
↑ ↑
2 0
Bits 0 and 2 are set to 1, while the remaining bits are 0.
This is why understanding hexadecimal is much more than learning another number system—it helps you interpret what is happening inside digital hardware.
11. Octal: The Number System You Still Occasionally Need
Octal is a base-8 number system.
It uses eight digits:
0 1 2 3 4 5 6 7
Each octal digit corresponds to three binary bits.
The relationship is:
| Binary | Octal |
|---|---|
| 000 | 0 |
| 001 | 1 |
| 010 | 2 |
| 011 | 3 |
| 100 | 4 |
| 101 | 5 |
| 110 | 6 |
| 111 | 7 |
For example:
110101₂
can be grouped into three-bit sections:
110 101
which gives:
6 5
Therefore:
110101₂ = 65₈
Octal is much less common in modern embedded development than hexadecimal, but it still appears in areas such as:
- Unix/Linux permissions
- Legacy computing systems
- Some older architectures and documentation
For example:
chmod 755
uses octal notation.
Each octal digit represents three permission bits.
So while hexadecimal is generally more important for modern electronics and embedded development, understanding octal is still useful.
12. Binary Arithmetic
Binary addition follows the same fundamental idea as decimal addition, but the carry occurs at 2 instead of 10.
The basic rules are:
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 10
The last rule is especially important.
In binary:
1 + 1 = 10₂
The result contains:
0 → write in the current position
1 → carry to the next position
Example: Binary Addition
Let’s calculate:
0101
+ 0011
------
1000
Working from right to left:
1 + 1 = 10
Write 0 and carry 1.
Continue through the remaining bits.
The final result is:
0101₂ + 0011₂ = 1000₂
In decimal:
5 + 3 = 8
Therefore:
1000₂ = 8₁₀
Binary arithmetic is fundamental because digital processors ultimately perform arithmetic using binary representations.
13. How Computers Represent Negative Numbers
Positive numbers are straightforward to represent in binary.
But how does a digital system represent a negative number such as:
−5
A common method is two’s complement.
Two’s complement is widely used for representing signed integers in digital systems.
Let’s represent −5 using 8 bits.
Step 1 — Write +5
00000101
Step 2 — Invert Every Bit
Change every 0 to 1 and every 1 to 0:
11111010
Step 3 — Add 1
11111010
+ 00000001
-----------
11111011
Therefore:
11111011₂
represents:
−5
in 8-bit two’s-complement representation.
Why Does This Work?
Two’s complement allows digital arithmetic hardware to handle positive and negative integers using the same basic binary addition circuitry.
For example:
00000101 +5
+ 11111011 -5
-----------
1 00000000
Ignoring the carry beyond the 8-bit range:
00000000
is zero.
This is one of the reasons two’s complement is so useful in digital computers.
Signed vs Unsigned 8-Bit Numbers
An 8-bit value can represent different ranges depending on how it is interpreted.
| Representation | Range |
|---|---|
| Unsigned | 0 to 255 |
| Signed two’s complement | −128 to +127 |
The same eight physical bits can therefore represent different numerical values depending on the interpretation being used.
14. Why Number Systems Matter in Embedded Systems
At first, number systems may look like pure mathematics.
In embedded systems, they become practical tools.
When you start programming microcontrollers, you’ll constantly encounter values such as:
0xFF
when configuring a register.
You may also encounter binary notation:
0b10101010
when examining individual bits.
Or a memory address such as:
0x08000000
The underlying hardware is working with binary states, but engineers often use hexadecimal because it provides a compact representation that is much easier to read.
This is the key connection:
Binary is fundamental to digital hardware; hexadecimal is a compact representation that makes binary data easier for engineers to work with.
For example:
Binary:
11111111
Hexadecimal:
0xFF
Decimal:
255
All three can represent the same numerical value.
The representation changes, but the underlying value does not.
15. A Practical Example: Reading a Register
Suppose a microcontroller register contains:
0xA5
Convert it to binary.
First convert each hexadecimal digit separately:
A = 1010
5 = 0101
Therefore:
0xA5 = 1010 0101₂
Now each bit can be examined individually:
1 0 1 0 0 1 0 1
This is exactly why hexadecimal is so common in embedded systems.
You can quickly move between:
Hex ↔ Binary ↔ Individual Bits
without performing a full decimal conversion.
16. Quick Reference
Number Systems
| System | Base | Example |
|---|---|---|
| Binary | 2 | 101101 |
| Octal | 8 | 55 |
| Decimal | 10 | 45 |
| Hexadecimal | 16 | 2D |
Bit Relationships
4 bits = 1 nibble
8 bits = 1 byte
2 hex digits = 1 byte
Important Conversions
Binary → Decimal
Multiply each bit by its corresponding power of 2 and add the results.
1011₂
= 1×8 + 0×4 + 1×2 + 1×1
= 11₁₀
Decimal → Binary
Repeatedly divide by 2 and read the remainders from bottom to top.
37₁₀ = 100101₂
Binary → Hexadecimal
Group the bits into sets of four.
1101 0010
↓ ↓
D 2
= 0xD2
Binary → Octal
Group the bits into sets of three.
110 101
↓ ↓
6 5
= 65₈
Two’s Complement
The basic procedure for obtaining the negative representation is:
Positive number
↓
Invert every bit
↓
Add 1
↓
Negative representation
17. Common Mistakes
Mistake 1: Reading Binary Like Decimal
A binary number such as:
1011₂
is not one thousand eleven.
Its value is:
8 + 2 + 1 = 11
Therefore:
1011₂ = 11₁₀
Always remember that the base determines the place values.
Mistake 2: Forgetting That A–F Are Hexadecimal Digits
In hexadecimal:
A = 10
B = 11
C = 12
D = 13
E = 14
F = 15
So:
0xF = 15
0x10 = 16
The hexadecimal number 10 does not mean decimal ten.
It means:
1 × 16 + 0 × 1 = 16
Mistake 3: Confusing Bits and Bytes
Remember:
8 bits ≠ 8 bytes
Instead:
8 bits = 1 byte
Therefore:
16 bits = 2 bytes
32 bits = 4 bytes
64 bits = 8 bytes
Mistake 4: Treating 0x as Part of the Numerical Value
The prefix:
0x
is a notation convention indicating that the following number is hexadecimal.
For example:
0x2F
means hexadecimal 2F.
The actual hexadecimal digits are:
2F
Mistake 5: Forgetting Leading Zeros
Leading zeros don’t change the numerical value.
For example:
101₂
and:
00000101₂
represent the same value.
But leading zeros are important when working with fixed-width data such as:
- 8-bit registers
- 16-bit registers
- 32-bit processors
- Memory addresses
For example:
0x05 = 00000101₂
Writing all eight bits makes the register representation easier to understand.
18. Try It Yourself
Don’t immediately look at the answers.
Try solving these problems yourself first.
Challenge 1
Convert:
101101₂
to decimal.
Challenge 2
Convert:
42₁₀
to binary.
Challenge 3
Convert:
11001111₂
to hexadecimal.
Challenge 4
Convert:
11110110₂
to hexadecimal.
Challenge 5
Represent:
−13
using 8-bit two’s complement.
Answers
1.
101101₂ = 45₁₀
2.
42₁₀ = 101010₂
3.
1100 1111
C F
11001111₂ = CF₁₆
4.
1111 0110
F 6
11110110₂ = F6₁₆
5.
Start with +13:
00001101
Invert:
11110010
Add 1:
11110011
Therefore:
−13 = 11110011₂
in 8-bit two’s complement.
19. Frequently Asked Questions
Why don’t computers simply use decimal?
Digital hardware operates using physical states that are naturally represented using binary logic.
A digital circuit can distinguish between two logical states, commonly represented as 0 and 1.
Decimal is convenient for humans, but binary maps naturally to digital bit states.
Why is hexadecimal so common in embedded systems?
Because one hexadecimal digit represents exactly four binary bits.
That means:
1 hex digit = 4 bits
2 hex digits = 8 bits = 1 byte
4 hex digits = 16 bits
8 hex digits = 32 bits
This makes hexadecimal compact and convenient for representing register values, memory addresses, and binary data.
How many values can N bits represent?
An unsigned N-bit quantity can represent:
2ᴺ
distinct combinations.
For example:
2⁸ = 256
So an unsigned 8-bit value can represent:
0 through 255
because there are 256 possible values.
Similarly:
16 bits → 2¹⁶ = 65,536 combinations
32 bits → 2³² = 4,294,967,296 combinations
Is octal still important?
Octal is much less common than hexadecimal in modern electronics and embedded development.
However, it still appears in areas such as:
- Unix/Linux permissions
- Legacy systems
- Older computing architectures
So you should understand the concept, but hexadecimal deserves greater attention for modern digital electronics and embedded systems.
Why does two’s complement use “invert and add 1”?
Two’s complement provides a representation of negative integers that allows digital systems to perform signed arithmetic using the same fundamental binary addition hardware.
The procedure is:
Write the positive number
↓
Invert every bit
↓
Add 1
This produces the corresponding negative representation within the selected bit width.
20. Final Takeaways
If you’re beginning digital electronics, you don’t need to memorize every conversion immediately.
Focus on these core relationships:
Binary → Base 2
Octal → Base 8
Decimal → Base 10
Hex → Base 16
And remember:
1 bit = 0 or 1
4 bits = 1 nibble
8 bits = 1 byte
1 hex digit = 4 bits
The most important practical relationship is:
Binary ↔ Hexadecimal
because every four binary bits correspond directly to one hexadecimal digit.
Finally:
Binary is the fundamental representation used by digital hardware, while hexadecimal provides engineers with a compact and readable way to represent binary data.
Once you are comfortable with number systems, you have one of the fundamental building blocks required for digital electronics, microcontrollers, embedded systems, computer architecture, and firmware development.
What’s Next?
Now that we understand how digital systems represent numerical information, the next question is:
How do digital circuits process those 0s and 1s?
That’s where logic gates come in.
In the next tutorial, we’ll build the foundation of digital logic by studying:
- AND
- OR
- NOT
- NAND
- NOR
- XOR
- XNOR
and learn how these simple gates combine to form the logic used inside real digital systems.
Next: Digital Logic Gates — AND, OR, NOT, NAND, NOR, XOR & XNOR


