DE Notes
Complete guide to the hexadecimal number system (base-16) covering hex digits, conversions between hex-binary-decimal-octal, hex arithmetic, and applications in computing.
The hexadecimal (hex) system is the most widely used compact notation for binary data in modern computing. Every byte can be represented by exactly two hexadecimal digits.
Fundamentals
Hex Digit Mapping
Positional Value
Hexadecimal to Decimal Conversion
Example: Convert 1A3F₁₆ to decimal
Decimal to Hexadecimal Conversion
Example: Convert 750₁₀ to hex
750 ÷ 16 = 46 remainder 14 (E) ← LSD
46 ÷ 16 = 2 remainder 14 (E)
2 ÷ 16 = 0 remainder 2 ← MSD
Read bottom to top: 750₁₀ = 2EE₁₆
Verify: 2×256 + 14×16 + 14 = 512 + 224 + 14 = 750 ✓
Hexadecimal to Binary (Direct Conversion)
Each hex digit = exactly 4 binary bits:
Example: Convert A7F2₁₆ to binary
Binary to Hexadecimal
Group binary digits in sets of 4 (from decimal point outward):
Example: Convert 110101011110₂ to hex
Hexadecimal to Octal Conversion
Convert through binary as intermediate:
Example: Convert 2F₁₆ to octal
| Step 1: Hex | Binary |
| Binary | 00101111 |
| Step 2: Binary | Octal (group by 3 from right) |
| Result | 2F₁₆ = 057₈ = 57₈ |
Hex Arithmetic
Hex Addition
| Example | 3A₁₆ + 4F₁₆ |
| Result | 3A₁₆ + 4F₁₆ = 89₁₆ |
| Verify | 58₁₀ + 79₁₀ = 137₁₀ = 89₁₆ ✓ (8×16 + 9 = 137) |
Hex Subtraction
| Example | C5₁₆ - 4A₁₆ |
| 5 - A | 5 < 10, borrow: (16+5) - 10 = 11 = B |
| Result | C5₁₆ - 4A₁₆ = 7B₁₆ |
| Verify | 197₁₀ - 74₁₀ = 123₁₀ = 7B₁₆ ✓ (7×16 + 11 = 123) |
Common Hex Values in Computing
| Color codes (RGB) | #FF0000 (Red), #00FF00 (Green), #0000FF (Blue) |
| Memory addresses | 0x7FFF (32K), 0xFFFF (64K), 0xFFFFFFFF (4G) |
| ASCII 'A' | 0x41 |
| Byte max | 0xFF = 255₁₀ |
| MAC address | AA:BB:CC:DD:EE:FF (6 bytes in hex) |
| IPv6 | 2001:0db8:85a3:0000:0000:8a2e:0370:7334 |
Hex Notation Conventions
| Context | Prefix/Suffix | Example |
|---|---|---|
| C/C++/Java | 0x prefix | 0x1A3F |
| Assembly | H suffix | 1A3FH |
| HTML/CSS | # prefix | #FF5733 |
| Verilog | h prefix in literal | 16'h1A3F |
| Mathematics | ₁₆ subscript | 1A3F₁₆ |
Why Hexadecimal Dominates Computing
| Binary | 11000000101010000000000100000001 (32 digits!) |
| Octal | 30052000401 (11 digits) |
| Hexadecimal | C0A80101 (8 digits - maps perfectly to 4 bytes) |
| Decimal | 3232235777 (10 digits - no clean bit boundary) |
| Winner | Hex - compact, maps cleanly to bytes and nibbles |
Interview Questions
Q1: Why is hexadecimal preferred for representing memory addresses? Each hex digit maps to exactly 4 bits, and two hex digits represent exactly one byte. A 32-bit address is exactly 8 hex digits, a 64-bit address is 16 hex digits. This clean mapping makes it easy to identify individual bytes and bit patterns visually, which is crucial for debugging and memory analysis.
Q2: Convert 0xDEADBEEF to decimal. D×16⁷ + E×16⁶ + A×16⁵ + D×16⁴ + B×16³ + E×16² + E×16¹ + F×16⁰ = 13×268435456 + 14×16777216 + 10×1048576 + 13×65536 + 11×4096 + 14×256 + 14×16 + 15 = 3,735,928,559₁₀
Q3: How do you quickly identify if a hex number is a power of 2? A power of 2 in hex will have exactly one bit set, meaning it will be one of: 1, 2, 4, 8 followed by all zeros. Examples: 0x100 = 256 = 2⁸, 0x8000 = 32768 = 2¹⁵. If the leading digit is 1, 2, 4, or 8 and all other digits are 0, it's a power of 2.
Q4: Why does hexadecimal use A-F instead of other characters? The letters A through F are the first six letters of the alphabet, providing a natural sequential extension after 0-9. This was standardized early in computing history. It keeps hex values compact (single characters) and maintains a clear ordering: 0<1<...<9<A<B<C<D<E<F.
Q5: What is 0xFF in signed vs unsigned interpretation for 8 bits? As unsigned 8-bit: 0xFF = 255₁₀ (all bits set). As signed 8-bit (two's complement): 0xFF = -1₁₀ (the two's complement representation of -1, since inverting gives 0x00 and adding 1 gives 0x01 = 1, so the original is -1).
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Hexadecimal Number System — Digital Electronics.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Digital Electronics topic.
Search Terms
digital-electronics, digital electronics, digital, electronics, number, systems, hexadecimal, system
Related Digital Electronics Topics