Binary & Hex Numbers
How computers count
Digital circuits know only two things: on and off, 1 and 0. Every number, every instruction, every pixel on your screen is encoded using just these two digits.
Understanding binary and hexadecimal is like learning to read the native language of hardware. It's simpler than you think.
Interactive Binary Counter
Click any bit to toggle it, or use the buttons to count. Watch how binary, decimal, and hex all represent the same number:
How Binary Works
In decimal (base 10), each position is worth 10 times the one to its right: ones, tens, hundreds, thousands. In binary (base 2), each position is worth twice the one to its right: 1, 2, 4, 8, 16, 32, 64, 128.
The number 42 in binary is 00101010: that's 0×128 + 0×64 + 1×32 + 0×16 + 1×8 + 0×4 + 1×2 + 0×1 = 32 + 8 + 2 = 42.
Counting in binary works just like decimal: when a digit maxes out, it rolls over to 0 and carries 1 to the next position. In decimal, 9 becomes 10. In binary, 1 becomes 10 (which equals decimal 2).
Why Hexadecimal?
Writing long binary strings is tedious and error-prone. Hexadecimal (base 16) solves this by using digits 0–9 and letters A–F, where each hex digit represents exactly 4 binary bits:
| Hex | Binary | Decimal |
|---|---|---|
| 0 | 0000 | 0 |
| 5 | 0101 | 5 |
| A | 1010 | 10 |
| F | 1111 | 15 |
| FF | 11111111 | 255 |
A byte (8 bits) is always exactly 2 hex digits. Writing 0xFF is much easier than 11111111. That's why engineers use hex constantly.
Why This Matters for FPGA Design
In FPGA design, binary and hex are everywhere:
- Data widths - every signal has a specific bit width (8-bit byte, 16-bit word, 32-bit register)
- Memory addresses - always written in hex (0x1000, 0xFFFF)
- Register values - configuration registers documented in hex
- Overflow - an N-bit counter wraps from 2N−1 back to 0
You'll use binary and hex thinking every single day of FPGA development.
Frequently Asked Questions
How does binary counting work?
Binary uses only two digits: 0 and 1. Each position represents a power of 2, just like decimal positions represent powers of 10. So binary 1011 means 1×8 + 0×4 + 1×2 + 1×1 = 11 in decimal. When a digit reaches 1, the next count rolls it to 0 and carries 1 to the next position, just like 9 rolls to 0 and carries 1 in decimal.
Why do engineers use hexadecimal?
Hexadecimal (base 16) is a compact way to write binary. Each hex digit represents exactly 4 binary digits, so a byte (8 bits) is always exactly 2 hex digits. Writing 0xFF is much easier to read and less error-prone than writing 11111111. Engineers use hex constantly when working with memory addresses, color codes, and register values.
Quick Check
Test your understanding of the key concepts from this lesson.





