Number systems, codes and Boolean algebra notes — Unit 1
Free unit-wise study notes on number systems, codes and boolean algebra for Digital Logic Design, Semester 3 of B.Tech — Computer Science & Engineering — key concepts, examples, important questions and a revision checklist for semester exams.
A foundational overview of how computers represent and manipulate data at the lowest level. Covers Binary/Octal/Hexadecimal arithmetic, standard codes (BCD, Gray, ASCII), and Boolean Algebra postulates.
Notebook — 14 pages
Page 1
Wink Notes
B.Tech CSE — 3rd Semester
Digital Logic Design
— Unit - 1 —
1. Analog vs Digital Signals
The physical world operates on analog signals, but modern computers process digital signals. Understanding the difference is the first step in digital logic.
⇒1.1 Analog Signals
Analog signals are continuous in both time and amplitude. They can take an infinite number of values within a given range.
Examples: Temperature variations, human voice, a mercury thermometer.
Drawbacks: Highly susceptible to noise and degradation over long distances. Hard to store accurately.
⇒1.2 Digital Signals
Digital signals are discrete in both time and amplitude. They only take specific, finite values (usually just two: High and Low, or 1 and 0).
Examples: Data in a computer's RAM, a digital watch.
Advantages: Immune to noise (a slightly degraded '1' is still read as a '1'). Easy to store, copy, and process perfectly.
Page 2
Wink Notes
B.Tech CSE — 3rd Semester
Digital Logic Design
— Unit - 1 —
2. Number Systems Overview
A number system defines how numbers are represented using a set of distinct symbols. The number of distinct symbols is called the Base or Radix (r).
⇒2.1 Positional Number Systems
In a positional system, the value of a digit depends on its position. A number N is represented as:
N=dnrn+dn−1rn−1+⋯+d1r1+d0r0+d−1r−1+…
⇒2.2 Common Number Systems in Computing
Decimal (Base-10): Symbols: 0 to 9. Used by humans.
Binary (Base-2): Symbols: 0, 1. Used by digital hardware because it perfectly maps to ON/OFF transistor states.
Octal (Base-8): Symbols: 0 to 7. Used as a shorthand for binary (groups of 3 bits).
Hexadecimal (Base-16): Symbols: 0-9, A-F (where A=10, F=15). Used as a more compact shorthand for binary (groups of 4 bits), heavily used in memory addresses and color codes.
Page 3
Wink Notes
B.Tech CSE — 3rd Semester
Digital Logic Design
— Unit - 1 —
3. Base Conversions: To Decimal
To convert a number from any base r to Decimal (Base-10), we use the Polynomial Expansion Method (multiplying each digit by its positional weight).
⇒3.1 Binary to Decimal
Convert (1011.01)2 to Decimal:
=1⋅23+0⋅22+1⋅21+1⋅20+0⋅2−1+1⋅2−2
=8+0+2+1+0+0.25
=(11.25)10
⇒3.2 Hexadecimal to Decimal
Convert (1A3)16 to Decimal:
=1⋅162+10⋅161+3⋅160
=256+160+3
=(419)10
Page 4
Wink Notes
B.Tech CSE — 3rd Semester
Digital Logic Design
— Unit - 1 —
4. Base Conversions: From Decimal
To convert from Decimal (Base-10) to any other base r, we use the Repeated Division Method for the integer part and the Repeated Multiplication Method for the fractional part.
0.50 × 2 = 1.00 (Record integer part 1. Since fractional part is 0, stop).
Read integers from top to bottom: (0.101)2.
Page 5
Wink Notes
B.Tech CSE — 3rd Semester
Digital Logic Design
— Unit - 1 —
5. Conversions: Binary ↔ Octal ↔ Hex
Because 8 (23) and 16 (24) are powers of 2, conversions between Binary, Octal, and Hexadecimal do not require going through Decimal. We use direct grouping.
⇒5.1 Binary to Octal
Group bits into sets of 3, starting from the binary point. Pad with leading/trailing zeros if necessary.
The easiest way is to convert Octal to Binary first, regroup the bits into 4s, and then convert to Hexadecimal (and vice versa).
Page 6
Wink Notes
B.Tech CSE — 3rd Semester
Digital Logic Design
— Unit - 1 —
6. Binary Arithmetic
Digital circuits perform arithmetic directly in binary.
⇒6.1 Binary Addition Rules
0+0=0
0+1=1
1+0=1
1+1=0 (with a carry of 1 to the next column)
1+1+1 (from previous carry) =1 (with a carry of 1)
⇒6.2 Binary Subtraction Rules
0−0=0
1−0=1
1−1=0
0−1=1 (with a borrow of 1 from the next column)
While direct binary subtraction is possible, modern computers do not use it. They use Complements (specifically 2's complement) to turn subtraction into an addition problem, allowing the ALU to only need an Adder circuit.
Page 7
Wink Notes
B.Tech CSE — 3rd Semester
Digital Logic Design
— Unit - 1 —
7. Complements
Complements are used in digital computers to simplify the subtraction operation and to represent negative numbers.
⇒7.1 1's Complement
The 1's complement of a binary number is found by flipping every bit: changing all 1s to 0s, and all 0s to 1s.
Example: 1's complement of `10110` is `01001`.
⇒7.2 2's Complement
The 2's complement of a binary number is found by taking its 1's complement and adding 1 to the Least Significant Bit (LSB).
Example: Find 2's complement of `10110`.
Step 1 (1's comp): `01001`
Step 2 (Add 1): `01001` + `1` = `01010`.
Shortcut: Starting from the right (LSB), leave all zeros and the first '1' unchanged. Then flip all remaining bits to the left.
Page 8
Wink Notes
B.Tech CSE — 3rd Semester
Digital Logic Design
— Unit - 1 —
8. Subtraction using Complements
To perform A−B, we compute A+(2’s complement of B).
⇒8.1 Subtraction rules using 2's Complement
Find the 2's complement of the subtrahend (B).
Add it to the minuend (A).
If a final carry is generated, discard it. The result is positive and in true binary form.
If NO final carry is generated, the result is negative and is in its 2's complement form. To find the magnitude, take the 2's complement of the result and attach a negative sign.
Example: Perform 7−4 using 4-bit 2's complement.
A=7=(0111)2
B=4=(0100)2. 2's complement of B=1100.
Add A and 2's comp of B: `0111 + 1100 = 1 0011`.
Discard the end carry (1). Result is `0011` (which is +3 in decimal). Correct!
Page 9
Wink Notes
B.Tech CSE — 3rd Semester
Digital Logic Design
— Unit - 1 —
9. Binary Coded Decimal (BCD)
In BCD (specifically 8421 BCD), each decimal digit is represented by a 4-bit binary equivalent.
Example: Decimal 396 in BCD is `0011` `1001` `0110`.
Note: BCD is NOT the same as direct binary conversion. (396)10=(110001100)2 in pure binary, which is only 9 bits. BCD uses 12 bits. BCD is less efficient in memory but easier for hardware to map to decimal displays (like 7-segment displays).
⇒9.1 BCD Addition
Add the two BCD numbers using regular binary addition.
If a 4-bit group sum is ≤9 and no carry was generated out of that group, the result is valid.
If a 4-bit group sum is >9 (invalid BCD code, e.g., 1010) OR if a carry was generated out of that group, the result is invalid.
Correction: Add `0110` (decimal 6) to the invalid 4-bit group to correct it and propagate any resulting carry to the next group.
Page 10
Wink Notes
B.Tech CSE — 3rd Semester
Digital Logic Design
— Unit - 1 —
10. Gray Code & Alphanumeric Codes
⇒10.1 Gray Code
Gray code is an unweighted code where successive numbers differ by exactly one bit.
Binary sequence: `000, 001, 010, 011` (Notice from 001 to 010, two bits change). Gray Code sequence: `000, 001, 011, 010` (Only one bit changes per step).
Application: Used in rotary encoders, Karnaugh maps, and error reduction in digital communications (because a single bit error only shifts the value by one increment).
⇒10.2 ASCII (American Standard Code for Information Interchange)
A 7-bit alphanumeric code used to represent text in computers. (128 characters: A-Z, a-z, 0-9, punctuation, and control characters like newline/CR). An 8th bit is often added for parity (error checking).
Page 11
Wink Notes
B.Tech CSE — 3rd Semester
Digital Logic Design
— Unit - 1 —
11. Introduction to Boolean Algebra
Boolean algebra is the mathematics of digital logic. It operates on binary variables (which take values 0 or 1) and three fundamental logic operations: AND (⋅), OR (+), and NOT (′).
⇒11.1 Huntington Postulates
The formal foundation of Boolean algebra.
Closure: Results of operations are within the set {0,1}.
Identity:x+0=x and x⋅1=x.
Commutative:x+y=y+x and x⋅y=y⋅x.
Distributive:x⋅(y+z)=(x⋅y)+(x⋅z) AND x+(y⋅z)=(x+y)⋅(x+z). (Notice the second one is unique to Boolean algebra, it doesn't work in standard algebra).
Complement: For every x, there is an x′ such that x+x′=1 and x⋅x′=0.
Page 12
Wink Notes
B.Tech CSE — 3rd Semester
Digital Logic Design
— Unit - 1 —
12. Theorems of Boolean Algebra
These theorems are used to minimize logic expressions, directly reducing the number of logic gates needed in a hardware circuit.
Idempotent Law:x+x=x and x⋅x=x.
Null (Dominance) Law:x+1=1 and x⋅0=0.
Involution Law:(x′)′=x.
Absorption Law:x+(x⋅y)=x and x⋅(x+y)=x.
⇒12.1 De Morgan's Theorems
The most important tool for manipulating negated logic:
Theorem 1:(x+y)′=x′⋅y′ (NOR is equivalent to Bubbled AND).
Theorem 2:(x⋅y)′=x′+y′ (NAND is equivalent to Bubbled OR).
Mnemonic: "Break the line, change the sign."
Page 13
Wink Notes
B.Tech CSE — 3rd Semester
Digital Logic Design
— Unit - 1 —
13. Logic Gates
Logic gates are the physical hardware implementation of Boolean functions. They are built using transistors.
⇒13.1 Basic Gates
AND Gate: Output is 1 only if ALL inputs are 1.
OR Gate: Output is 1 if AT LEAST ONE input is 1.
NOT Gate (Inverter): Output is the inverse of the input.
⇒13.2 Universal Gates
NAND and NOR are called Universal Gates because any boolean function (and any other gate) can be implemented using only NAND gates, or only NOR gates.
⇒13.3 Exclusive Gates
XOR (Exclusive-OR): Output is 1 if inputs are DIFFERENT (an odd-parity detector). A⊕B=A′B+AB′.
XNOR (Exclusive-NOR): Output is 1 if inputs are the SAME (an equality detector).
Page 14
Wink Notes
B.Tech CSE — 3rd Semester
Digital Logic Design
— Unit - 1 —
14. Summary & Review Checklist
Unit 1 sets the hardware-level vocabulary.
⇒14.1 University Exam Checklist
Convert (101.11)2 to Decimal, Octal, and Hexadecimal.
Perform (45)10−(62)10 using 8-bit 2's complement arithmetic.
Explain the rules of BCD addition. Why is 0110 added to invalid sums?
State De Morgan’s Theorems and prove them using a truth table.
Minimize the Boolean expression F=A′B′C+A′BC+AB′C+ABC using Boolean algebra theorems.
Why are NAND and NOR called Universal Gates? Prove it by constructing AND, OR, and NOT gates using only NAND gates.
⇒14.2 Placement Interview Focus
Bitwise operations in C/C++ (`&`, `|`, `^`, `~`) map directly to these logic gates. How would you use XOR to swap two variables without a temporary variable?
Why do computers use 2's complement instead of 1's complement to represent negative numbers? (Answer: 1's complement has two representations for zero, +0 and −0, which complicates ALU design).