Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
283 views

Module 2 Part II - Codes PDF

This document provides an introduction to representing numbers in binary form for use in digital computers. It discusses: 1. Number systems including decimal and binary, with binary using only the digits 0 and 1. Decimal numbers must be converted to binary for computer processing. 2. Binary arithmetic operations of addition, subtraction, multiplication and division using only two digits and their rules. 3. Examples are provided of converting decimal numbers to binary and performing binary arithmetic calculations.

Uploaded by

Chinee Amante
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
283 views

Module 2 Part II - Codes PDF

This document provides an introduction to representing numbers in binary form for use in digital computers. It discusses: 1. Number systems including decimal and binary, with binary using only the digits 0 and 1. Decimal numbers must be converted to binary for computer processing. 2. Binary arithmetic operations of addition, subtraction, multiplication and division using only two digits and their rules. 3. Examples are provided of converting decimal numbers to binary and performing binary arithmetic calculations.

Uploaded by

Chinee Amante
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 68

Module 2 (Part II) – CODES

GE 112
Mathematics in the Modern World

Ricky F. Rulete
Faculty, Math & Stat Department
College of Arts & Sciences
University of Southeastern Philippines
Outline
This module contains the following:
1. Introduction
2. Number Systems
 Decimal and Binary Numbers
 Arithmetic Operations
 Binary Codes
3. Integers and Computers
4. Logic and Computer Addition
5. Module Exercises
6. References

Outline Page 2
Introduction
Digital computers are devices capable of solving
problems by processing information in discrete form.

It operates on data, including magnitudes, letters, and


symbols, that are expressed in binary form, i.e., using
only two digits 0 and 1. However, people are
accustomed to the decimal system.

 To resolve this differences, decimal numbers are


converted to binary, perform all arithmetic
calculations in binary, and then convert the results
back to decimal.

Introduction Page 3
Introduction

Introduction Page 4
Introduction
 We must represent the decimal digits by a code that
contains 1s and 0s since computer can accept only
binary values.

 This method requires that we store the decimal


numbers in the computer in such a way that they
can be converted to binary.

Introduction Page 5
Number Systems
 a writing system for expressing numbers; that is,
a mathematical notation for representing
numbers of a given set, using digits or other
symbols in a consistent manner.
 a number 𝑁𝑟 with 𝑛 digits to the left of the
decimal point and 𝑚 digits to the right of the
decimal point in base 𝑟 contains 𝑟 digits
0,1,2, … , 𝑟 − 1, and is expressed as a power
series in 𝑟 with the general form
𝑛−1 −𝑚

𝑁𝑟 = 𝐴𝑖 𝑟 𝑖 + 𝐴𝑖 𝑟 𝑖
𝑖=0 𝑖=−1
where 𝐴𝑖 ∈ 0,1,2, … , 𝑟 − 1
1 Number Systems Page 6
Number Systems
 𝑟 is called the base or radix, the “.” is called the
radix point, 𝐴𝑛−1 is referred to as the most
significant digit (msd) and 𝐴−𝑚 as the least
significant digit (lsd) of the number
 When the number is expressed in positional
notation, only the coefficients and the radix point
are written down:
𝐴𝑛−1 𝐴𝑛−2 … 𝐴1 𝐴0 . 𝐴−1 𝐴−2 … 𝐴−𝑚+1 𝐴−𝑚

Note that if 𝑚 = 0, the lsd is 𝐴−0 = 𝐴0 .

1 Number Systems Page 7


Decimal Number System

• Decimal notation is the writing of numbers in a


base 10 numeral system.

• Examples are Roman numerals, Brahmi


numerals, and Chinese numerals, as well as the
Hindu-Arabic numerals used by speakers of
English.

1 Number Systems Page 8


Examples
Example 1. 𝑟 = 10, 𝐴𝑖 ∈ {0,1,2,3,4,5,6,7,8,9}

273.410 = 2 × 102 + 7 × 101 + 3 × 100 + 4 × 10−1


𝐴2 = 2 is the msd and 𝐴−1 = 4 is the lsd of
273.410
Example 2. 𝑟 = 5, 𝐴𝑖 ∈ {0,1,2,3,4}

324.15 = 3 × 52 + 2 × 51 + 4 × 50 + 1 × 5−1
= 75 + 10 + 4 + 0.2 = 89.210
𝐴2 = 3 is the msd and A−1 = 1 is the lsd of 324.15 ,
while 𝐴1 = 8 is the msd and A−1 = 2 is the lsd of
89.210
1 Number Systems Page 9
Binary Numbers
 𝑟 = 2, 𝐴𝑖 ∈ {0,1}
 A binary number is expressed with a string of 1s and
0s and, possibly, a binary point
 the binary system is used internally by all modern
computers
 Normally we count from left to right,
1 2 3 4 etc.
 In Binary we count in the opposite direction
8421
 It’s important to remember this in order to
convert your numbers.

1 Number Systems Page 10


Binary Numbers

 For instance

11012 = 1 × 23 + 1 × 22 + 0 × 21 + 1 × 20 = 1310

1101101.112 = 64 + 32 + 8 + 4 + 1 + 0.5 + 0.25


= 134.510

 The digits in a binary number are called bits.

1 Number Systems Page 11


Binary Numbers
Table 1. Powers of Two

𝒏 𝟐𝒏 𝒏 𝟐𝒏 𝒏 𝟐𝒏
0 1 8 256 -1 0.5
1 2 9 512 -2 0.25
2 4 10 1,024 -3 0.125
3 8 11 2,048 -4 0.0625
4 16 12 4,096 -5 0.03125
5 32 13 8,192 -6 0.015625
6 64 14 16,384 -7 0.0078125
7 128 15 32,768 -8 0.00390625

1 Number Systems Page 12


Binary Numbers
Conversion from decimal number 𝑁10 to binary number:
Steps:
1. Find the greatest number that is a power of two (see
Table 1) and that, subtracted from 𝑁10 , produces a
positive difference. Let the difference be designated 𝑀1 .
2. Repeat Step 1 applied to 𝑀1 . Let the difference be
designated 𝑀2 .
3. Continue this process until the difference is zero.
4. The equivalent binary number is obtained from the
coefficients of a power series that forms the sum of the
components. 1s appear in the binary number in the
positions for which terms appear in the power series,
and 0s appear in all other positions.
1 Number Systems Page 13
Binary Numbers
Example 3. Convert 62510 to its equivalent binary
number.
625 − 512 = 113 = 𝑀1 512 = 29
113 − 64 = 49 = 𝑀2 64 = 26
49 − 32 = 17 = 𝑀3 32 = 25
17 − 16 = 1 = 𝑀4 16 = 24
1 − 1 = 0 = 𝑀5 1 = 20

62510 = 29 + 26 + 25 + 24 + 20 = 10011100012

1 Number Systems Page 14


Binary Numbers
Example 4. Convert 0.687510 to its equivalent binary
number.
0.6875 − 0.5 = 0.1875 = 𝑀1 0.5 = 2−1
0.1875 − 0.125 = 0.0625 = 𝑀2 0.125 = 2−3
0.0625 − 0.0625 = 0 = 𝑀3 0.0625 = 2−4

0.687510 = 2−1 + 2−3 + 2−4 = 0.10112

NOTE: When no confusion arises, we will write the


binary numbers without base 2.

1 Number Systems Page 15


Arithmetic Operations
Addition Rules:
0+0=0 carry: 0
0+1=1 carry: 0
1+1=0 carry: 1

Example 5.

Carries: 00000 Carries: 101100


Augend: 01100 Augend: 10110
Addend: + 10001 Addend: + 10111
Sum: 11101 Sum: 101101

1 Number Systems Page 16


Arithmetic Operations
Subtraction Rules:
the same rule as in decimal, except that a borrow
into a given column adds 2 to the minuend bit

Example 6.

Borrows: 00000 Borrows: 00110


Minuend: 10110 Minuend: 10110
Subtrahend: − 10010 Subtrahend: − 10011
Difference: 00100 Difference: 00011

1 Number Systems Page 17


Arithmetic Operations
In the event that the subtrahend is larger than the
minuend, we subtract the minuend from the subtrahend
and give the result a minus sign.

Example 7.

Borrows: 00110
Minuend: 10011 11110
Subtrahend: −11110 − 10011
Difference: −01011

1 Number Systems Page 18


Arithmetic Operations
Multiplication Rules:
0×0=0 0×1=1 1×1=1

Example 8.
Multiplicand: 1011
Multiplier: × 101
1011
0000
1011
Product: 110111
Note: 10112 = 1110 , 1012 = 510 , 1101112 = 5510

1 Number Systems Page 19


Arithmetic Operations
Division Rules: the same rules as in decimal

Example 9.
10001
11001 110110110 17
11001 25 438
00100 25
00000 188
01001 175
00000 13
10011
00000
remainder
100110
11001
1101

1 Number Systems Page 20


Binary Codes
 An 𝑛-bit binary code is a group of 𝑛 bits that assume
up to 2𝑛 distinct combinations of 1s and 0s, with
each combination representing one element of the
set being coded
 A set of four elements can be coded with 2-bit
binary code, with each element assigned one of
the following bit combinations: 00, 01, 10, 11
 A set of 8 elements requires a 3-bit code, and a
set of 16 elements requires a 4-bit code

1 Number Systems Page 21


Binary Codes
 Each element must be assigned a unique binary bit
combination, and no two elements can have the
same value; otherwise, the code assignment is
ambiguous.
 A binary code will have some unassigned bit
combinations if the number of elements in the
set is not a power of 2.
 The ten decimal digits form such a set.
 A binary code that distinguishes among ten elements
must contain at least four bits (why?).

1 Number Systems Page 22


Binary Codes Types
 Weighted Codes Weighted codes and
 BDC (8421) nonweighted codes
 6311 are used to
 642-3 represent decimal
 Non-Weighted numbers
Codes
 Alphanumeric
 Excess-3
codes are used to
 Gray
represent the
 Alphanumeric
numeric and
Codes
nonnumeric data
 ASCII
(characters)
 EBCDIC

1 Inductive Reasoning 1 Page 23


Binary Codes Types
 Weighted Codes
 binary codes which obey positional weight
principle
 each position of the number represents a
specific weight
 used to express the decimal digits 0
through 9
 each decimal digit is represented
by a group of four bits
Note: Since 4 bits may have up to 16 different binary
combinations, a total of 6 combinations will be unused.
1 Number Systems Page 24
Binary Codes Types
Decimal BCD
BCD or Binary Coded Decimal Digit 8421
0 0000
• Also known as 8421 1 0001
code 2 0010

• Simplest form: 3 0011


4 0100
each decimal digit 5 0101
is replaced by its 6 0110
binary equivalent 7 0111
8 1000
• BCD is often used in 9 1001
business u 1010
n 1011
applications and u 1100
calculators. s
1101
e
d 1110
1111

1 Number Systems Page 25


Binary Codes Types
Decimal
Digit
BCD
8421
Example 10. Give the BCD code of
0 0000 the following
1 0001 a. 813.4510
2 0010
b. 94610
3 0011
4 0100 Solution:
5 0101 813.4510
6 0110
7 0111
8 1000 1000 0001 0011 0100 0101
9 1001
u 1010 813.4510 = 100000010011.01000101𝐵𝐶𝐷
n 1011
u
s
1100 94610 = 100101000110𝐵𝐶𝐷
1101
e
d 1110 Note: 94610 = 11101100102
1111
1 Number Systems Page 26
Binary Codes Types
Decimal
Digit
BCD
8421
Example 11. Give the decimal
0 0000 equivalent of
1 0001 0111001100000100𝐵𝐶𝐷 .
2 0010
Hint: Divide the BCD number into four-
3 0011
4 0100
bit groups and convert each to
5 0101 decimal.
6 0110
7 0111 Solution:
8 1000 0111 0011 0000 0100
9 1001
u 1010
n 1011
u
7 3 0 4
1100
s
1101 0111001100000100𝐵𝐶𝐷 = 730410
e
d 1110
1111
1 Number Systems Page 27
Binary Codes Types
Decimal BCD
Digit 8421 6311 642-3 Example 12. Give the 6311 and
0 0000 0000 0000 642-3 codes of the following
1 0001 0001 0101
a. 813.4510
2 0010 0011 0010
3 0011 0100 1001
b. 94610
4 0100 0101 0100
5 0101 0111 1011
Solution:
6 0110 1000 0110 813.4510
7 0111 1001 1101 = 101100010100.010101116311
8 1000 1011 1010
9 1001 1100 1111
813.4510
u 1010 0010 0001
= 101001011001.01001011642−3
n 1011 1010 0011
u
94610 = 1100010110006311
1100 0110 0111
s
e
1101 1101 1110 94610 = 111101000110642−3
d 1110 1110 1100
1111 1111 1000

1 Number Systems Page 28


Binary Codes Types
Decimal BCD Excess-3
Digit 8421
 Non-Weighted Codes 0 0000 0011
 binary codes which does not 1 0001 0100

obey the positional principle 2 0010 0101


3 0011 0110
Excess-3 Codes 4 0100 0111

• also known as XS-3 5 0101 1000


6 0110 1001
code 7 0111 1010
• binary codes are 8 1000 1011
derived from the BCD 9 1001 1100
1010 0000
code by adding 0011 u
n 1011 0001
(or 3) to each code. u 1100 0010
s
1101 1101
e
d 1110 1110
1111 1111

1 Number Systems Page 29


Binary Codes Types
Decimal BCD Excess-3
Digit 8421 (XS-3)
0 0000 0011
1 0001 0100
2 0010 0101
3 0011 0110
4 0100 0111 Example 13.
5 0101 1000
6 0110 1001
7 0111 1010 42610 = 011101011001𝑋𝑆−3
8 1000 1011
9 1001 1100
u 1010 0000
n 1011 0001
u 1100 0010
s
1101 1101
e
d 1110 1110
1111 1111

1 Number Systems Page 30


Binary Codes Types
Decimal BCD Gray Code
Digit 8421
Gray Codes 0 0000 0000

• also known as unit 1 0001 0001


2 0010 0011
distance code 3 0011 0010
• is a cyclic code 4 0100 0110

(successive code 5 0101 0111


6 0110 0101
words differ by only 7 0111 0100
one bit from one to 8 1000 1100

the next code 9 1001 1101


u 1010 1111

• cannot be used for n


u
1011 1110
1100 1010
arithmetic operation s
1101 1011
e
d 1110 1001
1111 1000

1 Number Systems Page 31


Binary Codes Types
Decimal BCD Gray Code
Digit 8421
0 0000 0000
1 0001 0001
2 0010 0011
3 0011 0010
4 0100 0110 Example 14.
5 0101 0111
6 0110 0101
7 0111 0100
42610 = 011000110101𝐺𝑟𝑎𝑦
8 1000 1100
9 1001 1101
u 1010 1111
n 1011 1110
u 1100 1010
s
1101 1011
e
d 1110 1001
1111 1000

1 Number Systems Page 32


Binary Codes Types
Alpha Numeric Codes
 codes that represents numbers and alphabet
characters

 represents other characters such as symbols and


various instructions necessary for conveying
information

 there are many choices of codes sets to represent


alphanumeric characters and several control
characters

1 Number Systems Page 33


Binary Codes Types

 Two well accepted code sets are used for information


coding:
 EBCDIC code: Extended Binary Code Decimal
Interchange Code
 uses 8-bit code
 28 = 256 possible code groups
 developed by IBM
 generally restricted to IBM and IBM-
compatible mainframe computers

1 Number Systems Page 34


Binary Codes Types

 ASCII code: American Standard Code for


Information Interchange
 uses 7-bit code
 27 = 128 possible code groups
 most personal computers use ASCII code

1 Number Systems Page 35


Binary Codes Types

1 Number Systems Page 36


Binary Codes Types

Example 15. The ASCII code for letter A is 1000001 and


is equivalent to 65 in decimal digit.

Example 16. Using the ASCII code, the word HELLO is


converted into

1001000 1000101 1001100 100100 1001111

1 Number Systems Page 37


Integers and Computers

2 Integers and Computers Page 38


Integers and Computers
• Computers use a fixed number of bits to represent an
integer.
• The commonly-used bit-lengths for integers are 8-bit,
16-bit, 32-bit or 64-bit. Besides bit-lengths, there are
two representation schemes for integers:
1. Unsigned Integers: can represent zero and
positive integers.
2. Signed Integers: can represent zero, positive
and negative integers. Three representation
schemes had been proposed for signed
integers:
a. Sign-Magnitude representation
b. 1's Complement representation
c. 2's Complement representation
2 Integers and Computers Page 39
Integers and Computers
𝑛-bit UNSIGNED INTEGERS
 Unsigned integers can represent zero and positive
integers, but not negative integers.
 The value of an unsigned integer is interpreted as
"the magnitude of its underlying binary pattern".
Example 17. Suppose that 𝑛 = 8 and the binary
pattern is 01000110, the value of this unsigned integer
is 1 × 26 + 1 × 22 + 1 × 21 = 7010
Example 18. Suppose that 𝑛 = 16 and the binary
pattern is 0001000000001000, the value of this
unsigned integer is
1 × 212 + 1 × 23 = 410410
2 Integers and Computers Page 40
Integers and Computers
𝑛-bit SIGNED INTEGERS in Sign-Magnitude
Representation
Converting from sign-magnitude notation to Decimal
Notation
 The most-significant bit (msb) is the sign bit, with
value of 0 representing positive integer and 1
representing negative integer.
 The remaining n-1 bits represents the magnitude
(absolute value) of the integer. The absolute
value of the integer is interpreted as "the
magnitude of the (n-1)-bit binary pattern".

2 Integers and Computers Page 41


Integers and Computers

Example 19. Suppose that 𝑛 = 8 and the binary


representation is 00100011. The sign bit is 0 means that it
is positive and the absolute value is
0100011 = 1 × 25 + 1 × 21 + 1 × 20 = 3510 .
Hence, the integer is +3510 .

Example 20. Suppose that 𝑛 = 8 and the binary


representation is 10001101. The sign bit is 1 means that
it is negative and the absolute value is
0001101 = 1 × 23 + 1 × 22 + 1 × 20 = 1310 .
Hence, the integer is −1310 .

2 Integers and Computers Page 42


Integers and Computers

Example 21. Suppose that 𝑛 = 8 and the binary


representation is 00000000. The sign bit is 0 means that
it is positive and the absolute value is
000000 = 010 .
Hence, the integer is +010 .

Example 22. Suppose that 𝑛 = 8 and the binary


representation is 10000000. The sign bit is 1 means that
it is negative and the absolute value is
000000 = 010 .
Hence, the integer is −010 .

2 Integers and Computers Page 43


Integers and Computers
The drawbacks of sign-magnitude representation are:
 There are two representations (00000000 and
10000000) for the number zero, which could lead to
inefficiency and confusion.
 Positive and negative integers need to be processed
separately.

2 Integers and Computers Page 44


Integers and Computers
Example 23. Let 𝑛 = 8. Write +63 in sign-magnitude form.

Solution: Since the integer is positive, the msd is 0 and


6310 = 0001111. Hence, the sign-magnitude form of
+63 is 00001111.

Example 24. Let 𝑛 = 8. Write -72 in sign-magnitude form.


Solution: Since the integer is negative, the msd is 1 and
7210 = 1001000. Hence, the sign-magnitude form of -72
is 11001000.

2 Integers and Computers Page 45


Integers and Computers
𝑛-bit SIGNED INTEGERS in 1’s Complement Representation
Converting from 1's Complement Notation to Decimal Notation
 Again, the most significant bit (msb) is the sign bit, with value
of 0 representing positive integers and 1 representing negative
integers.
 The remaining n-1 bits represents the magnitude of the
integer, as follows:
 for positive integers, the absolute value of the integer is
equal to "the magnitude of the (n-1)-bit binary pattern".
 for negative integers, the absolute value of the integer is
equal to "the magnitude of the complement (inverse) of
the (n-1)-bit binary pattern" (hence called 1's
complement). (e.g., the complement of 1011 is 0100)

2 Integers and Computers Page 46


Integers and Computers

Example 25. Suppose that 𝑛 = 8 and the binary


representation is 00100001. The sign bit is 0 means that
it is positive and the absolute value is
0100001 = 1 × 25 + 1 × 20 = 3310 .
Hence, the integer is +3310 .
Example 26. Suppose that 𝑛 = 8 and the binary
representation is 10100011. The sign bit is 1 means that
it is negative and the absolute value is the complement
of 0100011, i.e., 1011100 = 9210 . Hence, the integer is
−9210 .

2 Integers and Computers Page 47


Integers and Computers

Example 25. Suppose that 𝑛 = 8 and the binary


representation is 00000000. The sign bit is 0 means that
it is positive and the absolute value is
000000 = 010 .
Hence, the integer is +010 .

Example 26. Suppose that 𝑛 = 8 and the binary


representation is 11111111. The sign bit is 1 means that
it is negative and the absolute value is the complement
of 1111111, i.e., 0000000 = 010 . Hence, the integer is
−010 .

2 Integers and Computers Page 48


Integers and Computers
The drawbacks of 1’s Complement representation are:
 There are two representations (00000000 and
10000000) for the number zero.
 Positive and negative integers need to be
processed separately.

2 Integers and Computers Page 49


Integers and Computers
Converting from decimal notation to 1’s complement form
 if the given integer is positive, use the same
representation as unsigned with msd 0.
 if the given integer is negative,
• convert the magnitude of the positive integer to
binary
• take the complement of the resulting binary
Example 27. Let 𝑛 = 8. Convert -36 to its 1’s
complement form.
Solution.
3610 = 00100100 → take complement → 11011011
Hence, the 1’s complement of -36 is 11011011

2 Integers and Computers Page 50


Integers and Computers
𝑛-bit SIGNED INTEGERS in 2’s Complement Representation
Converting from 2's Complement Notation to Decimal
Notation
 Again, the most significant bit (msb) is the sign bit, with
value of 0 representing positive integers and 1
representing negative integers.
 The remaining n-1 bits represents the magnitude of the
integer, as follows:
 for positive integers, the absolute value of the integer is
equal to "the magnitude of the (n-1)-bit binary pattern".
 for negative integers, the absolute value of the integer
is equal to "the magnitude of the complement of the
(n-1)-bit binary pattern plus one" (hence called 2's
complement).
2 Integers and Computers Page 51
Integers and Computers

Example 28. Suppose that 𝑛 = 8 and the binary


representation is 00100101. The sign bit is 0 means that
it is positive and the absolute value is
0100101 = 1 × 25 + 1 × 23 + 1 × 20 = 4110 .
Hence, the integer is +4110 .

Example 29. Suppose that 𝑛 = 8 and the binary


representation is 10100011. The sign bit is 1 means that
it is negative and the absolute value is the complement
of 0100011 plus 1, i.e., 1011100 + 1 = 9310 . Hence,
the integer is −9310 .

2 Integers and Computers Page 52


Integers and Computers
Example 30. Suppose that 𝑛 = 8 and the binary
representation is 00000000. The sign bit is 0 means that it
is positive and the absolute value is
000000 = 010 .
Hence, the integer is +010 .

Example 31. Suppose that 𝑛 = 8 and the binary


representation is 11111111. The sign bit is 1 means that it
is negative and the absolute value is the complement of
1111111 plus 1, i.e., 0000000 + 1 = 110 . Hence, the
integer is −110 .

2 Integers and Computers Page 53


Integers and Computers

2 Integers and Computers Page 54


Integers and Computers
Converting from decimal to 2’s complement form
 if the given integer is positive, use the same
representation as unsigned with msd 0.
 if the given integer is negative, determine the 1’s
complement and add 1.
Example 32. Let 𝑛 = 8. Convert -36 to its 2’s complement
form.
Solution.
3610 = 00100100 → take complement → 11011011
Hence, the 1’s complement of -36 is 11011011. Then add
1 to 11011011 and obtain 11011100. Thus, the 2’s
complement of -36 is 11011100.

2 Integers and Computers Page 55


Logic and Computer Addition

 Any arithmetic operation in a computer system can


be implemented using basic logical operations, such
as AND and OR

 These logical operations have truth tables


associated with them, which enumerate the output
signals for particular combinations of inputs.

3 Logic and Computer Addition Page 56


Logic and Computer Addition

3 Logic and Computer Addition Page 57


Logic and Computer Addition
Recall: Binary Number Addition

A B Sum Carry
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1

3 Logic and Computer Addition Page 58


Logic and Computer Addition
A circuit for binary addition:

This circuit is called a half-adder. (It doesn’t take


any carry)

3 Logic and Computer Addition Page 59


Logic and Computer Addition
The Full Adder Circuit

3 Logic and Computer Addition Page 60


Logic and Computer Addition

3 Logic and Computer Addition Page 61


Logic and Computer Addition

3 Logic and Computer Addition Page 62


Exercises
1. Write your name in ASCII.
2. Use the table of ASCII binary codes to decode this:
Character Decimal ASCII Binary ASCII Binary Decimal Character
Value Code Code Value

U 1001101

S 1000001

1010100
e
1001000

P 1000101

4 Module Exercises Page 63


Exercises
3. Complete the following table:

binary decimal 6311 642-3 XS-3 Gray


BCD
number number code code code Code

8510

101101

01110011

10110011

10010110

4 Module Exercises Page 64


Exercises
4. Perform the indicated operation:
10011 01111 01101
+ 01101 + 01011 + 01100

11101 01001 11101


- 01011 - 00101 - 01011

4 Module Exercises Page 65


Exercises
5. Perform the indicated operation:
10011 01111 01101
× 01101 × 01011 × 01100

01011 111011 11001 10101011

4 Module Exercises Page 66


Exercises
6. Complete the following table for integer representation
using 8-bit:

Unsigned 2’s
Decimal Sign-Magnitude 1’s Complement
integer Complement

−5110
00101100
10110011
11001101

4 Module Exercises Page 67


References

1. Morris Mano M., Kime C., Logic and Computer


Design Fundamentals (4th Edition), Pearson
Education Limited 2014.
2. Stevens A., CS101 Lecture06: Logic Gates +
Binary Addition = The Adder
3. www.ntu.edu.sg/home/ehchua/programming/ja
va/datarepresentation.html
4. www.youtube.com/watch?v=VBDoT8o4q00

References Page 68

You might also like