CA - Unit 1 - SEP-1
CA - Unit 1 - SEP-1
UNIT – I
2
Decimal Number System
Decimal number system is a base 10 number system having 10 digits from 0
to 9.
This means that any numerical quantity can be represented using these 10
digits.
Decimal number system is also a positional value system.
This means that the value of digits will depend on its position
Say we have three numbers – 734, 971 and 207. The value of 7 in all three
numbers is different−
In 734, value of 7 is 7 hundreds or 700 or 7 × 100 or 7 × 102
In 971, value of 7 is 7 tens or 70 or 7 × 10 or 7 × 101
In 207, value 0f 7 is 7 units or 7 or 7 × 1 or 7 × 100
3
Binary Number System
4
Octal Number System
Octal number
system has eight
digits – 0, 1, 2, 3, 4, 5,
6 and 7.
Octal number system
Decimal equivalent of any octal number is sum of
is also a positional
product of each digit with its positional value.
value system with 7268 = 7×82 + 2×81 + 6×80
where each digit has = 448 + 16 + 6
its value expressed in = 47010
powers of 8
5
Hexadecimal Number System
Hexadecimal number
system has 16 symbols – 0
to 9 and A to F where A is
equal to 10, B is equal to 11
and so on till F.
6
Number System Conversions
Binary to Decimal
Decimal conversion is The binary number
done to convert a system is used in
number given in the computers and
binary number electronic systems
system to its to represent data
equivalent value in and it consists of
the decimal number only two digits
The binary number which are 0 and 1.
system.
system has a base of 2
because it has only two
digits to represent any
number.
8
Binary to Decimal
Step 2: Now multiply each digit in the binary number starting from the right with
its respective weight based on its position and evaluate the product.
Step 3: Now, express the binary number as a decimal number: 1011012 = 4510
9
Exercises
Convert 11102, from binary to decimal using the binary to decimal
formula.
Convert 11112, from binary to decimal using the binary to decimal
formula.
Convert 10102, from binary to decimal using the binary to decimal
formula.
10
Decimal to Binary Then, the
Decimal to remainders are
binary conversion is noted down till we
done through get 0 as the final
various methods. quotient. After this
One of the methods step, these
to convert decimal remainders are
to binary is by written in reverse
dividing the given order to get the
decimal number binary value of the
recursively by 2. given decimal
number.
11
Decimal to binary conversion
To convert numbers
from decimal to binary,
the given decimal
number is divided
repeatedly by 2 and
the remainders are
noted down till we get
0 as the final quotient.
12
Exercises
25
39
72
55
13
Decimal to Octal
In the number system, each of the types has its own base number i.e. octal
number has a base number of 8 and the decimal number has a base number of
10.
To convert decimal to octal, we need to divide the decimal number by the octal
base number 8 and write the acquired remainder in reverse to derive at the
equivalent octal number.
14
Convert Decimal to Octal
15
Example
Convert the decimal number (85)10 to an octal number.
Step 1: Check if the decimal number is less than 8. If yes, the octal number is
the same. If no, then proceed forward. In this case, 85 is more than 8 so let's go
to step 2.
Step 2: Divide 85 by 8 (octal base number).
Note down the quotient and the remainder in the quotient-remainder form.
Repeat this process (dividing the quotient again by 8) until we get the quotient
to be less than 8.
16
Example
17
Exercises
67
99
350
18
Octal to decimal
19
20
Exercises
(121)8
(454)8
21
Hexadecimal Number System
22
Conversion from Hex to Decimal
Convert 7CF (hex) to decimal.
Given hexadecimal number is 7CF.
In hexadecimal system,
7=7
C = 12
F = 15
To convert this into a decimal number system, multiply each digit with the powers
of 16 starting from units place of the number.
7CF = (7 × 162) + (12 × 161) + (15 × 160)
= (7 × 256) + (12 × 16) + (15 × 1)
= 1792 + 192 + 15
= 1999
23
Convert (1DA6)16 to decimal.
Convert (E8B)16 to decimal system.
(2bf)16
24
Conversion from Decimal to Hexadecimal number
system
25
Convert 60010 into a hexadecimal number.
26
Binary to octal Conversion
27
Octal to Binary Conversion
28
Hexa Decimal to Binary Conversion
29
Binary to Hexa Decimal Number
(1000101)2
30
Octal to Hexa Decimal Number
Step1: Convert Octal to Binary
Group 4 bits together and represent equivalent hexa decimal digit
31
Hexa decimal to Octal conversion
Step1: Convert Hexa decimal to binary
Step2: Regrouping the bits into 3 bits
32
Complements
Complements
complement number system An alternative representation of numbers in
a fixed-radix number system
Complements are used in the digital computer in order to simplify the
subtraction operation and for logical manipulation.
For Each Radix system( Radix r represents the number system)
There are 2 types of Complements(r, r-1) complements
r-radix complement,r-1=Diminished radix complement.
34
Binary system Complements
There are 2 complements in Binary System
1. 1’s Complement
2. 2’s complement
35
1’s Complement
To generate a 1’s complement for any given binary number, you only
need to invert that number.
For a binary number like 110010, the 1’s complement would be 001101.
36
2’s complement
To generate a 2’s complement for any given binary number, you need to invert
it. Then you need to add 1 to the LSB (Least Significant Bit) of the generated
result.
1’s complement + 1
37
Complements of numbers
The r and r-1’s complement can be found for all the number systems.
Basically there are 4 number systems and hence r and r-1’s complements can
be found for only these 4 number systems.
r-1 )’s Complement
•Given a number N in base r having n digits,
•the (r- 1)’s complement of N is defined as
(rn - 1) - N
•For decimal numbers the
base or r = 10 and r- 1= 9,
•so the 9’s complement of N 9 9 9 9 9
is (10n-1)-N
•99999……. - N
- Digit
n
Digit
n-1
Next
digit
Next
digit
First
digit
9’s complement Examples
546700= 453299 4 5 3 2 9 9
- 1 2 3 8 9
8 7 6 1 0
Note: Similarly we can find the r and (r-1)’s complements for any given number of
octal and hexadecimal numbers also
r’s Complement
•100000……. - N
Number Systems Arithmetic
Binary Arithmetic
42
Binary Addition
43
Addition using 2’s complement
The 2’s complement is most commonly used code for processing positive
and negative binary numbers. There are 4 different cases
1. Both the numbers are positive
2. Larger of 2 numbers are positive
3. The larger of 2 numbers are negative
4. Both the numbers are negative
44
Case 2: Larger of 2 numbers are positive
Example: 1101 and -1001
First, find the 2's complement of the negative number 1001. So, for finding 2's complement,
change all 0 to 1 and all 1 to 0 or find the 1's complement of the number 1001. The 1's
complement of the number 1001 is 0110, and add 1 to the LSB of the result 0110. So the 2's
complement of number 1001 is 0110+1=0111
Add both the numbers, i.e., 1101 and 0111;
1101+0111=1 0100
By adding both numbers, we get the end-around carry 1. We discard the end-around carry. So,
the addition of both numbers is 0100.
45
Case 3: The larger of 2 numbers are negative
Example: 1101 and -1110
First, find the 2's complement of the negative number 1110. So, for finding 2's
complement, add 1 to the LSB of its 1's complement value 0001.
0001+1=0010
Add both the numbers, i.e., 1101 and 0010;
1101+0010= 1111
Find the 2's complement of the result 1110 that is the final result. So, the 2's complement
of the result 1110 is 0001, and add a negative sign before the number so that we can
identify that it is a negative number.
46
Case 4: Both the numbers are negative
Example: -1101 and -1110 in five-bit register
Firstly find the 2's complement of the negative numbers 01101 and 01110. So, for finding
2's complement, we add 1 to the LSB of the 1's complement of these numbers. 2's
complement of the number 01110 is 10010, and 01101 is 10011.
We add both the complement numbers, i.e., 10001 and 10010;
10010+10011= 1 00101
By adding both numbers, we get the end-around carry 1. This carry is discarded and the
final result is the 2.s complement of the result 00101. So, the 2's complement of the result
00101 is 11011, and we add a negative sign before the number so that we can identify
that it is a negative number.
47
Binary Subtraction
Binary subtraction is one of the four binary operations, where we perform the
subtraction method for two binary numbers (comprising only two digits, 0 and
1).
This operation is similar to the basic arithmetic subtraction performed on
decimal numbers in Maths.
Binary Subtraction
0–0=0
1–0=1
1–1=0
0 – 1 = 1 (Borrow 1)
48
Case i) Binary subtraction without borrowing
Case ii) Binary subtraction with borrowing
49
Case ii) Binary subtraction with borrowing:
50
Binary Subtraction Using 2's
Complement
Step 1: Determine the 2’s complement of the smaller number
Step 2: Add this to the larger number.
Step 3: Omit the carry. Note that there is always a carry in this case.
51
Binary Multiplication
The binary multiplication is very much similar to the usual multiplication method of
integers.
First, we need to multiply each digit of one binary number to each digit of another binary
number.
52
Binary Division
The binary division operation is similar to
the base 10 decimal system, except the base 2.
The division is probably one of the most
challenging operations of the basic arithmetic operations.
Solve 01111100 ÷ 0010
53
Octal Arithmetic
Octal rules are similar to the decimal or binary arithmetic.
This number system is normally used to enter long strings of binary data into a
digital system like a microcomputer.
The information can be handled only in binary form in a digital circuit and
it Is easier to enter the information using hexadecimal number system.
Introduction:
Although binary data is the most efficient storage scheme;
every bit pattern represents a unique, valid value. However,
some applications may not be desirable to work with binary
data.
For instance, the internal components of digital clocks keep
track of the time in binary. The binary value must be
converted to decimal before it can be displayed.
Binary Coded Decimal
Add 6 to
Answer is sum to Add 6 to
correct no get sum to
correction correct get
required answer correct
answer
BCD arithmetic
BCD Addition
BCD subtraction
Two methods:
1. 9’s complement method
2. 10’s complement method
BCD subtraction using 9’s
complement
Perform BCD subtraction using 9’s
complement method (A)10 - (B)10
1. Obtain 9’s complement of no. B
3. If carry is generated in step 2 then add it to sum to obtain final result. The
4. If carry is not produced then the result is negative hence take 9’s complement
of the result.
Examples
Perform (8)10 - (3)10
8
9’s complement
of 3
Ex.
Ex.
Ex.
Solve following subtraction of decimal
numbers using 9’s complement method.
Digital data is represented, stored and transmitted as groups of binary digits also known as binary
code.
Weighted codes: In weighted codes, each digit is assigned a specific weight according to its position.
Non-weighted codes: In non-weighted codes are not appositionally weighted.
Reflective codes: A code is reflective when the code is self complementing. In other words, when the code for 9 is the
complement the code for 0, 8 for 1, 7 for 2, 6 for 3 and 5 for 4.
Sequential codes: In sequential codes, each succeeding 'code is one binary number greater than its preceding code.
Alphanumeric codes: Codes used to represent numbers, alphabetic characters, symbols
Error defecting and correcting codes: Codes which allow error defection and correction are called error detecting and'
correcting codes.
Non-weighted binary code.
Computers work with only 0’s and 1’s. However, there is a need for more advanced
forms of communication with machines. This is why alphanumeric code is
important. It includes 26 characters for the letters of the alphabet, and 10 more for
symbols like !@#$%^&.
1-5 ALPHANUMERIC CODES - ASCII Character Codes
Chapter 1
90
Alphanumeric code represents both numbers and alphabetical characters. The most
common types of alphanumeric code are EBCDIC and ASCII.
American Standard Code for Information Interchange
This code is a popular code used to represent information sent as character-based
data. It uses 7-bits to represent:
94 Graphic printing characters.
34 Non-printing characters
Some non-printing characters are used for text format (e.g. BS = Backspace, CR =
carriage return)
Other non-printing characters are used for record marking and flow control (e.g.
STX and ETX start and end text areas).
ASCII Character Code
91
EBCDIC
EBCDIC stands for Extended Binary Coded Decimal Interchange Code. EBCDIC code is an 8-bit code that is mainly used
in IBM mainframe and IBM midrange computer operating systems.
UNICODE
Unicode is an international character encoding standard that provides a unique number for every character
across languages and scripts, making almost all characters accessible across platforms, programs, and devices.
Unicode is a universal character encoding standard. This standard includes roughly 100000 characters to
represent characters of different languages. While ASCII uses only 1 byte the Unicode uses 4 bytes to represent
characters. Hence, it provides a very wide variety of encoding. It has three types namely UTF-8, UTF-16, UTF-
32. Among them, UTF-8 is used mostly it is also the default encoding for many programming languages.
Error detection and correction code plays an important role in the transmission of
data from one source to another. The noise also gets added into the data when it
transmits from one system to another, which causes errors in the received binary
data at other systems. The bits of the data may change(either 0 to 1 or 1 to 0)
during transmission.
It is impossible to avoid the interference of noise, but it is possible to get back the
original data. For this purpose, we first need to detect either an error z is present
or not using error detection codes. If the error is present in the code, then we will
correct it with the help of error correction codes.
Error-Detecting Code
96
100
101
A Digital Computer Example
Memory
Control
CPU unit Datapath
Synchronous or
Asynchronous?
Transfer of information
102
Digital
Concerned with the interconnection among digital components and
modules
Best Digital System example is General Purpose
Computer
Logic Design
Deals with the basic concepts and tools used to design digital
hardware consisting of logic circuits
Circuits to perform arithmetic operations (+, -, x, ÷)
Digital Signal : Decimal values are difficult to represent in electrical systems. It
106 is easier to use two voltage values than ten.
on off
Power switches have labels “1” for on and “0” for off.
Binary Logic
107
Definition of Binary Logic
Binary logic consists of binary variables and a set of logical operations.
The variables are designated by letters of the alphabet, such as A, B, C, x, y, z, etc, with
each variable having two and only two distinct possible values: 1 and 0,
Three basic logical operations: AND, OR, and NOT.
Binary Logic gates
Truth Tables, Boolean Expressions, and Logic Gates
AND OR NOT
x y z x y z x z
0 0 0 0 0 0 0 1
0 1 0 0 1 1 1 0
1 0 0 1 0 1
1 1 1 1 1 1
z=x•y=xy z=x+y z = x = x’
x x x
y z y z z
Universal Gate
NAND and NOR Gates are called Universal Gates because AND, OR
and NOT gates can be implemented &created by using these gates.
112
Truth Table:
Boolean function can be uniquely and completely described by truth table.
A truth table lists all possible values of input combinations of the function and
produces the output for all combinations.
Rule in Boolean Algebra:
Variable used can have only two values. Binary 1 for HIGH and Binary 0 for LOW.
Complement of a variable is represented by an over bar (-). Thus, complement of
variable B is represented as . Thus if B = 0 then = 1 and B = 1 then = 0.
OR ing of the variables is represented by a plus (+) sign between them. For example
OR ing of A, B, C is represented as A + B + C.
Logical AND ing of the two or more variable is represented by writing a dot between
them such as A.B.C. Sometime the dot may be omitted like ABC.
113
Boolean Laws
There are six types of Boolean Laws.
1. Commutative law
2. Associative law
3. Distributive law
4. AND law
5. OR Law
6. INVERSION law
114
Commutative law:
Any binary operation which satisfies the following expression is referred to as
commutative operation.
Commutative law states that changing the sequence of the variables does
not have any effect on the output of a logic circuit.
Associative law:
This law states that the order in which the logic operations are performed is
irrelevant as their effect is the same.
115
Distributive law:
Distributive law states the following condition.
AND law:
These laws use the AND operation. Therefore they are called as AND laws.
OR law
These laws use the OR operation. Therefore they are called as OR laws.
INVERSION law:
This law uses the NOT operation. The inversion law states that double inversion
of a variable results in the original variable itself.
116
Duality Principle:
According to the duality principle, if we have theorems of Boolean Algebra for any one
type of operation then the operation can be converted into another type of operation.
In other words AND can be converted to OR and OR can be converted into AND
We can interchange '0 with 1', '1 with 0', '(+) sign with (.) sign' and '(.) sign with (+)
sign' to perform dual operation. T
117
De Morgan's Theorem
This theorem explains that the complements of the products of all the terms are equal
to the sums of the complements of each and every term
Likewise, the complements of the sums of all the terms are equal to the products of the
complements of each and every term.
There are 2 theorems in DeMorgan’s
1. Theorem 1:
2. Theorem 2:
118
Theorem 1: This theorem explains that the complements of the products of all the terms
are equal to the sums of the complements of each and every term
The LHS (left-hand side) of this theorem represents the NAND gate that has inputs A
and B. On the other hand, the RHS (right-hand side) of this theorem represents the OR
gate that has inverted inputs.
The OR gate here is known as a Bubbled OR.
119
120
Theorem 2: The complements of the sums of all the terms are equal to the products of
the complements of each and every term.
The left-hand side of this theorem represents the NOR gate that has inputs A and B. On
the other hand, the right-hand side represents the AND gate that has inverted inputs.
The AND gate here is known as a Bubbled AND.
121
122
Draw a logic diagram
for the following
expression:
(a)
ab+b’c+c’a’
(b) (a+b).
(a+b’).c
123
Function Minimization using Boolean
Algebra
Show that;
1. ab + ab' = a
ab + ab' = a(b+b') = a.1=a
2.
(a + b)(a + b') = a
(a + b)(a + b') = a.a +a.b' +a.b+b.b'
= a + a.b' +a.b + 0
= a + a.(b' +b) + 0
= a + a.1 +0
= a +a
= a
Function Minimization using Boolean
Algebra
Examples:
(a) a + ab = a(1+b)=a
A B C Minterm
0 0 0 0 m0 ABC
1 0 0 1 m1 ABC
2 0 1 0 m2 ABC
3 0 1 1 m3 ABC
4 1 0 0 m4 ABC
5 1 0 1 m5 ABC
6 1 1 0 m6 ABC
7 1 1 1 m7 ABC
128 /
28
Converting from Truth Table to Boolean
Function
A B C Maxterm
0 0 0 0 M0 A B C
1 0 0 1 M1 A B C
2 0 1 0 M2 A B C
3 0 1 1 M3 A B C
4 1 0 0 M4 A B C
5 1 0 1 M5 A B C
6 1 1 0 M6 A B C
7 1 1 1 M7 A B C
129 /
28
Converting from Truth Table to Boolean Function
Truth Table to Boolean Function
A B C F F A BC A BC A BC ABC
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 1
1 1 0 0
1 1 1 1
Using
Minterms 130 /
28
Converting from Truth Table to Boolean Function
Truth Table to Boolean Function
F ( A B C ) ( A B C )( A B C ) ( A B C )
A B C F
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 0 Using
Maxterms 131 /
28
Converting from Truth Table to Boolean Function
Sum of Minterms A B C F F
F A BC A BC A BC ABC 0 0 0 0 0 1
1 0 0 1 1 0
F m1 m4 m5 m7
2 0 1 0 0 1
F (1,4,5,7)
3 0 1 1 0 1
•Product of Maxterms 4 1 0 0 1 0
F A BC ABC ABC ABC 5 1 0 1 1 0
F A BC ABC ABC ABC 6 1 1 0 0 1
7 1 1 1 1 0
F A BC ABC ABC ABC
F ( A B C )( A B C )( A B C )( A B C )
F M 0 M2 M3 M6
F (0,2,3,6) 132 /
28
Karnaugh Maps
Karnaugh maps (K-maps) are graphical representations of
Boolean functions.
One map cell corresponds to a row in the truth table.
Also, one map cell corresponds to a minterm or a maxterm in the
Boolean expression
Multiple-cell areas of the map correspond to standard terms.
A K-map provides a systematic method for simplifying Boolean
expressions and, if properly used, will produce the simplest SOP
or POS expression possible, known as the minimum expression.
What is K-Map
It’s similar to truth table; instead of being organized (i/p
and o/p) into columns and rows, the K-map is an array of
cells in which each cell represents a binary value of the
input variables.
The cells are arranged in a way so that simplification of a
given expression is simply a matter of properly grouping
the cells.
K-maps can be used for expressions with 2, 3, 4, and 5
variables.
Karnaugh Map
2-variable K-map
3-variable Karnaugh map
AB\C 0 1
A\BC 00 01 11 10
00 0 1 0 0 1 3 2
1 4 5 7 6
01 2 3
11 6 7
10 4 5
Three-Variable K-Maps
BC BC BC BC
A 00 01 11 10 A 00 01 11 10 A 00 01 11 10 A 00 01 11 10
0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 1 1
1 1 0 0 0 1 1 1 0 0 1 1 1 0 0 1 0 0 0 0
BC BC BC BC
A 00 01 11 10 A 00 01 11 10 A 00 01 11 10 A 00 01 11 10
0 0 1 1 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 1
1 0 0 0 0 1 1 0 0 1 1 0 0 0 0 1 1 0 0 1
The 4-variable Karnaugh Map
The 4-variable karnaugh map is an array of sixteen cells
Binary values of A and B are along the left side and the
values of C and D are across the top.
AB\CD 00 01 11 10
00 0 1 3 2
01 4 5 7 6
11 12 13 15 14
10 8 9 11 10
Determining the Minimum SOP Expression
from the Map
CD
00 01 11 10 B A C AC D
AB
00 1 1 AC
01 1 1 1 1 B
11 1 1 1 1
AC D
10 1
Four-Variable K-Maps
CD CD CD CD
AB 00 01 11 10 AB 00 01 11 10 AB 00 01 11 10 AB 00 01 11 10
00 1 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0
01 0 0 0 0 01 0 1 0 0 01 0 0 0 0 01 1 0 0 1
11 0 0 0 0 11 0 1 0 0 11 0 1 1 0 11 0 0 0 0
10 1 0 0 0 10 0 0 0 0 10 0 0 0 0 10 0 0 0 0
CD CD CD CD
00 01 11 10 00 01 11 10 00 01 11 10 00 01 11 10
AB AB AB AB
00 0 0 1 1 00 0 0 0 0 00 0 0 1 1 00 1 0 0 1
01 0 0 1 1 01 1 0 0 1 01 0 0 0 0 01 0 0 0 0
11 0 0 0 0 11 1 0 0 1 11 0 0 0 0 11 0 0 0 0
10 0 0 0 0 10 0 0 0 0 10 0 0 1 1 10 1 0 0 1