Unit 1: Number Systems
Digital electronics processes information encoded as discrete symbols rather than continuous quantities. This unit establishes how numeric information is represented, converted, arithmetically manipulated, and protected against errors inside digital hardware.
I. Foundations of Digital Systems
Digital systems manipulate quantities that take only a finite set of values (typically two: 0 and 1), and every later topic depends on this discreteness and its coding conventions.
- Digital Systems: Systems that store and process information as discrete levels; a two-state (binary) system maps HIGH voltage to logic 1 and LOW voltage to logic 0, giving strong noise immunity.
- Data representation and coding: Any datum (number, character, image sample) is reduced to a string of bits; a code is the agreed rule mapping symbols to bit patterns (e.g., ASCII maps 'A' to 65).
- Logic circuits: Physical realisation using gates (AND, OR, NOT) that compute Boolean functions of binary inputs; combinational circuits give outputs from present inputs, sequential circuits add memory.
- Implementation of digital systems: Built from SSI/MSI gates, programmable devices (PLA, FPGA), or microprocessors; design flow is specification → Boolean function → gate netlist → hardware.
- Analog vs Digital:
- Analog: Continuous values (e.g., a 0–5 V signal takes infinite intermediate values); sensitive to noise and drift.
- Digital: Quantised values; regenerable, storable, and reproducible without degradation, at the cost of quantisation error.
II. Positional Number Systems
A. Positional number system
A positional system assigns each digit a weight equal to the base raised to the digit's position.
- Radix (base) r: Number of distinct digits; decimal uses r = 10, binary r = 2.
- Weight rule: A number is
Σ dᵢ · rⁱ, where dᵢ is the digit and i the position index (0 at the least significant, negative for fractions).
(345.2)₁₀ = 3·10² + 4·10¹ + 5·10⁰ + 2·10⁻¹B. Number Systems
- Common bases: Decimal (10), Binary (2), Octal (8), Hexadecimal (16).
- Digit range: Each base uses digits 0 to r−1; hexadecimal extends with A–F for 10–15.
C. Codes
- Definition: A systematic assignment of bit patterns to information units.
- Types anticipated: Weighted numeric codes (BCD), unweighted (Gray), and redundant codes (parity, Hamming) covered in later sections.
III. Binary Number System
A. Binary number system
The base-2 system is the natural language of two-state hardware.
- Digits: Only 0 and 1, each a bit; 8 bits = 1 byte.
- Positional weights: …, 8, 4, 2, 1 for integers; ½, ¼, … for fractions.
(1011.1)₂ = 8 + 0 + 2 + 1 + 0.5 = (11.5)₁₀B. Octal number system
- Base 8: Digits 0–7; each octal digit equals exactly three binary bits (
(101 110)₂ = (56)₈). - Use: Compact shorthand for long binary strings.
C. Hexadecimal number system
- Base 16: Digits 0–9 and A–F; each hex digit equals four binary bits (
(1101 0110)₂ = (D6)₁₆). - Use: Dominant in memory addresses and machine-code display.
IV. Base Conversions
A. Methods of base conversions
Conversion moves a value between radices while preserving its magnitude.
- Any base → decimal: Multiply each digit by its positional weight and sum.
- Decimal integer → any base: Repeated division by r, reading remainders bottom-up.
- Decimal fraction → any base: Repeated multiplication by r, reading carries top-down.
(45)₁₀ → binary:
45/2=22 r1 ; 22/2=11 r0 ; 11/2=5 r1 ; 5/2=2 r1 ; 2/2=1 r0 ; 1/2=0 r1
Read up: (101101)₂B. Number base conversions
- Binary ↔ octal/hex: Group bits in 3s (octal) or 4s (hex) from the radix point.
- Octal ↔ hex: Route through binary as an intermediate (
(17)₈ = 001 111 = 0000 1111 = (F)₁₆).
V. Binary Arithmetic
A. Binary arithmetic
Arithmetic follows base-10 rules with carries/borrows resolved at 2.
- Addition rules: 0+0=0, 0+1=1, 1+1=10 (write 0, carry 1).
- Subtraction: Uses borrow of value 2; commonly replaced by complement addition.
- Multiplication/division: Shift-and-add / shift-and-subtract.
1011 (11)
+ 0110 (6)
------
10001 (17)B. Octal arithmetic
- Carry at 8: Sum digits; if ≥ 8, subtract 8 and carry 1 (
(7)₈+(5)₈ = 12+? → 7+5=12₁₀ = (14)₈).
C. Hexadecimal arithmetic
- Carry at 16: Add using decimal equivalents; if ≥ 16, subtract 16 and carry 1 (
(9)₁₆+(8)₁₆ = 17₁₀ = (11)₁₆).
VI. Complements and Signed Numbers
A. Compliments
Complements let subtraction be performed by addition, simplifying hardware.
- (r−1)'s complement: Subtract each digit from r−1 (1's complement in binary = bit inversion).
- r's complement: Add 1 to the (r−1)'s complement (2's complement in binary).
1's comp of 0101 = 1010
2's comp of 0101 = 1010 + 1 = 1011B. Representation of signed numbers
- Sign–magnitude: MSB is the sign, remaining bits the magnitude; has two zeros (+0, −0).
- 1's complement: Negatives are bitwise inversion; also two zeros.
- 2's complement: Negatives via r's complement; single zero, unique and standard in CPUs. Range for n bits: −2ⁿ⁻¹ to 2ⁿ⁻¹−1.
−5 (4-bit, 2's comp) = 2's comp of 0101 = 1011C. Fixed numbers
- Fixed-point representation: The radix point sits at a fixed, implied position; integer and fraction fields have preset widths.
- Trade-off: Simple, fast hardware but limited dynamic range compared with floating point.
VII. Floating Point Numbers
A. Floating point numbers
Floating point represents very large and very small values by storing a scaled fraction and an exponent.
- Form:
value = (−1)^S × M × 2^E, where S is sign, M the mantissa (significand), E the exponent. - Normalisation: Mantissa scaled so one nonzero digit precedes the point; keeps precision.
- IEEE 754 single precision: 1 sign bit, 8 exponent bits (bias 127), 23 mantissa bits.
+6.5 = +110.1₂ = 1.101 × 2² → S=0, E=2+127=129, M=101000…VIII. Binary Codes
A. Binary Codes
Codes translate decimal or symbolic data into bit patterns for storage and transmission.
- Weighted vs unweighted: Weighted codes assign positional value to bits (8421); unweighted do not (Gray).
B. Binary coded decimal codes
- BCD (8421): Each decimal digit is coded separately in 4 bits (
59 → 0101 1001). - Feature: Wastes patterns 1010–1111 but eases decimal display and error-free decimal I/O.
C. Gray codes
- Reflected code: Successive values differ in exactly one bit, minimising switching errors in encoders.
- Conversion:
gᵢ = bᵢ ⊕ bᵢ₊₁(binary → Gray, MSB unchanged).
Binary 0110 → Gray: 0, 0⊕1=1, 1⊕1=0, 1⊕0=1 → 0101IX. Error Detection and Correction
A. Error Detection and Correction
Redundant bits added to data let a receiver detect or repair corruption caused by noise.
- Redundancy principle: Only certain bit patterns are valid codewords; a received non-codeword signals an error.
- Hamming distance: Minimum bit differences between codewords; distance d detects d−1 errors and corrects ⌊(d−1)/2⌋.
B. Error detection code
- Purpose: Flag that corruption occurred, without locating it; retransmission then requested.
- Examples: Parity, checksum, cyclic redundancy check (CRC).
C. Parity check codes
- Scheme: Append one bit so the total number of 1s is even (even parity) or odd (odd parity).
- Limitation: Detects any odd number of bit errors, misses even-count errors.
Data 1011 (three 1s) → even parity bit = 1 → 10111D. Parity
- Even parity: Parity bit makes 1-count even.
- Odd parity: Parity bit makes 1-count odd; choice fixed by protocol.
E. Error correction code
- Purpose: Both detect and pinpoint erroneous bits so they can be inverted, avoiding retransmission.
- Requirement: Larger minimum Hamming distance and multiple check bits.
F. Hamming code
Hamming code inserts multiple parity bits at power-of-two positions to locate a single-bit error.
- Check bits: k bits satisfy
2^k ≥ m + k + 1for m data bits. - Positions: Parity bits at 1, 2, 4, 8, …; each checks a fixed subset of positions.
- Correction: The parity checks form a binary syndrome whose value gives the failing bit position; a zero syndrome means no error.
7-bit code (4 data, 3 parity): syndrome 101 = position 5 is wrong → flip bit 5.Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →