Module 1 Computer Fundamentals
Introduction to Number System and Codes
A number system is a way to represent and express numbers using a specific set of symbols
(digits) and a base (radix). In computer systems, number systems are fundamental because
computers operate on binary digits (bits).
Number System Base Digits Used Example
Decimal 10 0–9 459, 82.5
Binary 2 0, 1 1011₂
Octal 8 0–7 745₈
Hexadecimal 16 0–9, A–F 2F₁₆, 1A3₁₆
Why Do We Use Different Codes in Digital Systems?
Digital systems use codes to represent numbers, characters, and symbols in binary form. These
are called binary codes.
Common Binary Codes:
Code Type Purpose Example
BCD (Binary-Coded Represents decimal digits in binary (4 bits per
59 = 0101 1001
Decimal) digit)
Only one-bit changes at a time (used in Binary 3 = 011, Gray
Gray Code
encoders to reduce error) = 010
ASCII Represents text characters in computers 'A' = 65 = 01000001
Unicode Extended character set for all languages 'अ' = U+0905
3 → 0110 (binary 3 +
Excess-3 Code BCD variant used in error detection
0011)
Applications of Codes
BCD: Digital clocks, calculators
Gray Code: Rotary encoders, error correction
ASCII/Unicode: Text representation in programming and data transfer
Understanding number systems and codes helps students:
Design and debug logic circuits
Understand how data is stored and processed
Work with assembly language, memory addresses, and low-level programming
Prepare for advanced topics like ALU design, microprocessor architecture, and digital
logic design
Number Systems: Binary, Octal, Decimal, Hexadecimal
A digital system can understand positional number system.
In this system, there are a few symbols called digits which represent different values
depending on the position they occupy in the number.
A value of each digit in a number can be determined using:
o The digit
o The position of the digit in the number
o The base of the number system (where base is defined as the total number of
digits available in the number system).
There are different types of number system like binary, decimal, hexadecimal and octal.
Decimal Number System:
The number system that we use in our day-to-day life is the decimal number system.
Decimal number system has base 10 as it uses 10 digits from 0 to 9.
Each position represents a specific power of the base (10).
Binary Number System:
Uses two digits, 0 and 1. Also called base 2 number system
Each position in a binary number represents a power of the base (2). Position 1 in LSB
represents 20
Example: Binary Number: 101012. Calculating Decimal Equivalent –
Octal Number System:
Uses eight digits, 0,1,2,3,4,5,6,7.
Also called base 8 number system
Each position in an octal number represents a power of the base (8). Example: Position 1
in LSB represents 80
Example: Octal Number − 125708
Calculating Decimal Equivalent –
Hexadecimal Number System:
Uses 10 digits and 6 letters, 0,1,2,3,4,5,6,7,8, 9, A, B, C, D, E, F.
Letters represent numbers starting from 10. A = 10, B = 11, C = 12, D = 13, E = 14, F =
15.
Also called base 16 number system.
Each position in a hexadecimal number represents a power of the base (16). Example:
Position 1 in LSB represents 160.
Example: Hexadecimal Number: 19FDE16
Calculating Decimal Equivalent –
Number System Conversion:
There are many methods or techniques which can be used to convert numbers from one base to
another:
Decimal to Other Base System
Other Base System to Decimal
Other Base System to Non-Decimal
o Binary to Octal
o Octal to Binary
o Binary to Hexadecimal
o Hexadecimal to Binary
o Octal to Hexadecimal
o Hexadecimal to Octal
Decimal to Other Base System:
The steps are as follows:
Step 1 − Divide the decimal number to be converted by the value of the new base.
Step 2 − Get the remainder from Step 1 as the rightmost digit (least significant digit) of new base
number.
Step 3 − Divide the quotient of the previous divide by the new base.
Step 4 − Record the remainder from Step 3 as the next digit (to the left) of the new base number.
Repeat Steps 3 and 4, getting remainders from right to left, until the quotient becomes zero in
Step 3.
The last remainder thus obtained will be the Most Significant Digit (MSD) of the new base
number.
Example:
Decimal Number: 2910
Calculating Binary Equivalent –
As mentioned in Steps 2 and 4, the remainders have to be arranged in the reverse order so that
the first remainder becomes the Least Significant Digit (LSD) and the last remainder becomes
the Most Significant Digit (MSD).
Decimal Number − 2910 = Binary Number − 111012.
Other Base System to Decimal System:
The steps are as follows:
Step 1 − Determine the column (positional) value of each digit (this depends on the position of
the digit and the base of the number system).
Step 2 − Multiply the obtained column values (in Step 1) by the digits in the corresponding
columns.
Step 3 − Sum the products calculated in Step 2. The total is the equivalent value in decimal.
Example:
Binary Number − 111012
Calculating Decimal Equivalent −
Binary Number − 111012 = Decimal Number − 2910
Other Base System to Non-Decimal System
Binary to Octal:
Step 1 − Divide the binary digits into groups of three (starting from the right).
Step 2 − Convert each group of three binary digits to one octal digit.
Example:
Binary Number − 101012
Calculating Octal Equivalent −
Binary Number − 101012 = Octal Number − 258
Octal to Binary:
Step 1 − Convert each octal digit to a 3-digit binary number (the octal digits may be treated as
decimal for this conversion).
Step 2 − Combine all the resulting binary groups (of 3 digits each) into a single binary number.
Example
Octal Number − 258
Calculating Binary Equivalent –
Octal Number − 258 = Binary Number − 101012
Binary to Hexadecimal:
Step 1 − Divide the binary digits into groups of four (starting from the right).
Step 2 − Convert each group of four binary digits to one hexadecimal symbol.
Example
Binary Number − 101012
Calculating hexadecimal Equivalent –
Binary Number − 101012 = Hexadecimal Number − 1516
Hexadecimal to Binary:
Step 1 − Convert each hexadecimal digit to a 4-digit binary number (the hexadecimal digits may
be treated as decimal for this conversion).
Step 2 − Combine all the resulting binary groups (of 4 digits each) into a single binary number.
Example
Hexadecimal Number − 1516
Calculating Binary Equivalent –
Hexadecimal Number − 1516 = Binary Number − 101012
Octal (Base-8) and Hexadecimal (Base-16) are both number systems used for compact binary
representation. While they don’t convert directly, we use Binary as an intermediate step for
accurate conversion.
Why Use Binary as an Intermediate?
Octal → Binary: Each digit = 3 bits
Hex → Binary: Each digit = 4 bits
So, we convert:
Octal → Binary → Hexadecimal
Hexadecimal → Binary → Octal
Octal to Hexadecimal:
Steps:
1. Convert each octal digit to 3-bit binary.
2. Combine all binary groups.
3. Regroup binary into 4-bit chunks (from right).
4. Convert each 4-bit binary to hex digit.
Example: Convert (735)₈ to Hex.
Step 1: Octal → Binary
7 → 111
3 → 011
5 → 101
So, (735)₈ = 111 011 101 (binary)
Step 2: Group 4 bits from right → 1 1101 1101
Pad with 0s on left: 0001 1101 1101
Step 3: Binary → Hex
0001 → 1
1101 → D
1101 → D
Final Answer: (735)₈ = (1DD)₁₆
Hexadecimal to Octal:
Steps:
1. Convert each hex digit to 4-bit binary.
2. Combine all binary groups.
3. Regroup binary into 3-bit chunks (from right).
4. Convert each 3-bit group to octal digit.
Example: Convert (2F)16 to Octal
Step 1: Hex → Binary
2 → 0010
F → 1111
So, (2F)₁₆ = 0010 1111
Step 2: Group in 3 bits (from right): 00 101 111
Pad left if needed: 000 101 111
Step 3: Binary → Octal
000 → 0
101 → 5
111 → 7
Final Answer: (2F)16 = (057)8
Binary Number representation: Sign Magnitude, 1’s and 2’s Compliment representation
Sign-Magnitude Notation
Definition:
o Simplest method of representing positive and negative numbers around zero (0).
o Negative numbers are obtained by changing the sign of the corresponding positive
number.
o Example pairs: (+2, −2), (+10, −10).
Binary Representation:
o Binary digits (bits) have only two values: 0 or 1.
o Sign also has two values: “+” or “−”.
o A single bit can be used to represent the sign.
Sign Bit Convention:
o Most Significant Bit (MSB) is the sign bit.
0 → Positive number.
1 → Negative number.
Magnitude Bits:
o Remaining n−1 bits represent the magnitude in unsigned binary format.
Example:
o 8-bit signed binary for decimal +53: 0 0110101
o 0 = sign bit (positive), 0110101 = magnitude.
Positive Signed Binary Numbers
Negative Signed Binary Numbers
Disadvantages of Sign-Magnitude Notation
Convert the following decimal values into signed binary numbers using the sign-magnitude
format:
One’s Complement of a Signed Binary Number
Definition:
Another method to represent negative binary numbers in a signed binary number system.
Positive numbers (non-complements) remain unchanged, just like in Sign-Magnitude
representation.
Negative Numbers:
Obtained by taking the one’s complement (bit inversion) of the positive number.
Positive numbers start with 0 → complement will start with 1 (indicating negative).
How to Take One’s Complement:
Change each bit: 1 → 0 and 0 → 1.
Example: One’s complement of 1001010₂ = 0110101₂.
Two’s Complement
Definition:
o Another method for representing negative binary numbers in a signed binary
system.
o Positive numbers are represented the same way as unsigned binary.
o A negative number is represented so that:
Positive Number + Negative Number=0
How It Works:
o Negative number = One’s complement of its positive equivalent + 1.
o Subtraction is done as:
A−B=A + (Two’s complement of B)
Advantages:
o No double-zero problem (only one zero: 0000₂).
o Easy to generate using simple hardware logic.
o Simplifies arithmetic operations in computers.
Subtraction using 1s complement
Method:
1's complement subtraction steps:
1. At first, find 1's complement of the B(subtrahend).
2. Then add it to the A(minuend).
3. If the final carry over of the sum is 1, then it is dropped and 1 is added to the result.
4. If there is no carry over, then 1's complement of the sum is the final result and it is
negative.
1. Find Subtraction of 110 and 101 using 1's complement method
Here A = 110, B = 101.
Find A - B =? using 1's complement
First find 1's complement of B = 101
Note: 1's complement of a number is obtained by subtracting all bits from 111
(or flip the bits)
1's complement of 101 is
Now Add this 1's complement of B to A
The left most bit of the result is called carry and add it to the rest part of the result
000.
2. Find Subtraction of 10110 and 11101 using 1's complement method
Here A = 10110, B = 11101.
Find A - B =? using 1's complement
First find 1's complement of B = 11101
Note: 1's complement of a number is obtained by subtracting all bits from 11111.
1's complement of 11101 is
Now Add this 1's complement of B to A
Here there is no carry, answer is - (1's complement of the sum obtained 11000)
Subtraction using 2s complement
Method:
2's complement subtraction steps:
1. At first, find 2's complement of the B(subtrahend).
2. Then add it to the A(minuend).
3. If the final carry over of the sum is 1, then it is dropped and the result is positive.
4. If there is no carry over, then 2's complement of the sum is the final result and it is negative.
1. Find Subtraction of 110 and 101 using 2's complement method
Here A = 110, B = 101.
Find A - B =? using 2's complement
First find 2's complement of B = 101
Note: 2's complement of a number is 1 added to its 1's complement number.
1's complement of 101 is
Now add 1: 010 + 1 = 011
Now add this 2's complement of B to A
The left most bit of the result is called carry and it is ignored.
So answer is 001
2. Find Subtraction of 10110 and 11101 using 2's complement method
Here A = 10110, B = 11101.
Find A - B =? using 2's complement
First find 2's complement of B = 11101
Note: 2's complement of a number is 1 added to it's 1's complement number.
1's complement of 11101 is
Now add 1: 00010 + 1 = 00011
Now add this 2's complement of B to A
Here there is no carry, answer is - (2's complement of the sum obtained 11001)
Note: 2's complement of a number is 1 added to its 1's complement number.
1's complement of 11001 is
Now add 1: 00110 + 1 = 00111
So answer is -00111
Logic Gates: AND, OR, NOT, NAND, NOR, EX-OR
What are Logic Gates?
Logic gates execute basic logical functions that are fundamental to digital circuits. These basic
gates are the basis of more complex digital devices and systems that enable our computers,
smartphones, and other digital devices to function.
What are Truth Tables?
The truth table displays the logical operations on input signals in a table format. Every Boolean
expression can be viewed as a truth table. The truth table identifies all possible input
combinations and the output for each. It is common to create the table so that the input
combinations produce an unsigned binary up-count.
AND Gate
An AND gate produces a high output (1) only if all its inputs are high. If one or more of an AND
gate's inputs are low (0), it produces a low output.
The name "AND gate" is derived from its function: if we label 0 as "false" and 1 as "true," the
gate mimics the behavior of the logical "and" operation.
Symbol:
Truth Table
A B Output
0 0 0
0 1 0
1 0 0
1 1 1
OR Gate
An OR gate produces a high output (1) if one or more of its inputs are high. If all inputs are low,
it produces a low output.
The "OR gate" is named for its resemblance to the logical inclusive "or" operation. The output is
"true" when at least one of the inputs is "true." However, if both inputs are "false," the output
remains "false." Simply put, the output will be 1 if either input one OR input two is 1.
Symbol:
Truth Table
A B Output
0 0 0
0 1 1
0 0 1
1 1 1
NOT (Inverter) Gate
A NOT gate inverts its input. If the input is high (1), the output is low (0), and vice versa.
Often referred to as a “NOT” gate to distinguish it from other electronic inverter types, a logical
inverter has a single input and flips the logic state. Specifically, an input of 1 yields an output of
0.
Symbol:
Truth Table
A Output
0 1
1 0
NOTE: AND, OR, NOT gates are called as primary gates because
1. AND, OR, and NOT gates perform the most fundamental logical operations: conjunction,
disjunction, and negation, respectively.
2. More complex gates like NAND, NOR, XOR, and XNOR are derived from these three basic
gates by combining them in different ways.
NAND (NOT AND) Gate
A NAND gate is the inverse of the AND gate. It produces a low output (0) only if all its inputs
are high.
The NAND gate functions like a combination of an AND gate succeeded by a NOT gate. It
essentially performs the logical "and" operation and then negates the result. The output becomes
"false" only when both inputs are "true"; for all other input combinations, the output is "true."
Symbol:
Truth Table
A B Output
0 0 1
0 1 1
1 0 1
1 1 0
NOR (NOT OR) Gate
A NOR gate is the inverse of the OR gate. It produces a high output (1) only if all its inputs are
low. Its output is "true" if both inputs are "false." Otherwise, the output is "false."
Symbol:
Truth Table
A B Output
0 0 1
0 1 0
1 0 0
1 1 0
XOR (Exclusive OR) Gate
An XOR gate produces a high output (1) only if an odd number of its inputs are high. For two-
input XOR gates, this means the output is high only when one input is high and the other is low.
The XOR gate, standing for "exclusive-OR," operates similarly to the logical "either/or" concept.
The output is "true" when one, and only one, of the inputs is "true." It becomes "false" if both
inputs are the same, whether "true" or "false." Essentially, the output is 1 when the inputs differ
and 0 when they match.
Symbol:
Truth Table
A B Output
0 0 0
0 1 1
1 0 1
1 1 0
XNOR (Exclusive NOR) Gate
An XNOR gate produces a high output (1) if an even number of its inputs are high. For two-
input XNOR gates, this means the output is high when both inputs are identical, either both high
or both low.
Symbol:
Truth Table
A B Output
0 0 1
0 1 0
1 0 1
1 1 0
NOTE: NAND and NOR are called as universal logic gates.
In Boolean Algebra, the NAND and NOR gates are called universal gates because any digital
circuit can be implemented by using any one of these two i.e. any logic gate can be created using
NAND or NOR gates only.
Implementation of AND Gate using Universal Gates
1. Implementation using NAND Gates
The AND gate can be implemented by using two NAND gates in the below fashion:
2. Implementation using NOR Gates
Implementation of AND gate using only NOR gates as shown below:
Implementation of OR Gate using Universal Gates
1. Implementation Using NAND Gates
The OR gate can be implemented using the NAND gate as below:
2. Implementation using NOR Gates
Implementation of OR gate using two NOR gates as shown in the picture below:
Implementation of NOT Gate using Universal gates.
Implementation using NAND Gates
Implementation Using NOR Gates
Basic Organization of Computer, Von Neumann model
The Von Neumann architecture, proposed by John von Neumann in 1945, is a foundational
design for modern computers. It is characterized by the stored-program concept, meaning both
instructions (the program) and data are stored in the same memory unit and accessed via a single
bus.
A PC that stores data and programmed instructions to read-write in RAM is built on Von
Neumann Architecture.
The components of a computer built on Von Neumann Architecture include:
1. Central Processing Unit (CPU):
The "brain" of the computer, responsible for executing instructions and processing data. It
comprises:
Arithmetic Logic Unit (ALU): Performs arithmetic operations (addition,
subtraction) and logical operations (AND, OR, NOT).
Control Unit (CU): Manages and coordinates the flow of data and instructions
throughout the system, fetching instructions from memory, decoding them, and
directing the ALU and other components.
Registers: Small, fast storage locations within the CPU used to hold data and
instructions temporarily during processing (e.g., Program Counter, Accumulator,
Instruction Register).
2. Main Memory:
A single, unified storage unit where both program instructions and data are stored. Each memory
location has a unique address, allowing the CPU to access specific instructions or data.
3. Input/Output (I/O) Devices:
Devices that allow the computer to interact with the external world.
Input Devices: Provide data and instructions to the computer (e.g., keyboard,
mouse).
Output Devices: Display or present processed information from the computer
(e.g., monitor, printer).
4. Buses:
Sets of electrical conductors that provide pathways for communication between the components:
Address Bus: Carries memory addresses from the CPU to memory or I/O devices.
Data Bus: Carries data and instructions between the CPU, memory, and I/O
devices.
Control Bus: Carries control signals from the CPU to other components,
managing operations like read/write requests and timing.
Working Principle:
The heart of the Von Neumann architecture is the fetch-decode-execute cycle, a continuous
process that allows the computer to carry out instructions:
1. Fetch: The CPU retrieves an instruction from memory.
2. Decode: The CPU interprets the instruction to determine what operation needs to be
performed.
3. Execute: The CPU performs the required action, which might involve calculations, data
manipulation, or controlling other components.
4. Store (optional): The result of the execution is stored back into memory if necessary.
Advantages
Simplified Design: The single memory space simplifies hardware design and
manufacturing, leading to lower costs.
Flexibility: The ability to store both data and instructions in the same memory allows
computers based on this architecture to run various programs and be easily
reprogrammed
Disadvantage: Since instructions and data share the same memory and bus, there can be a
bottleneck known as the "Von Neumann bottleneck" where the CPU might have to wait for data
or instructions to be transferred.