0% found this document useful (0 votes)
4 views

CSC201_Week3-Module2

Uploaded by

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

CSC201_Week3-Module2

Uploaded by

jobdenno1
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

COURSE CODE : CSC 201

Introduction to Computer Science

Topic: Data Storage and Internal Representation II

Week 3 – Module 2

DR(MRS) O.E.OJO
1
• Character Representation
- Binary Addition
- One’s complement
- Two’s Complement

2
3
4
Computer Arithmetic

The arithmetic and logic unit of the


central processor in a computer
performs all its arithmetic by addition
and shifting.
Binary addition 810 10002
+710 01112
1510 11112
5
Binary multiplication

510 X 210
510 - 1 0 12

X 210 - 0 1 02

• 0 0 0

• 1 0 1

0 0 0

• 1010= 0 1 0 1 02 6
7
One’s Complement
• The one’s complement of a binary number is
defined as the value obtained by inverting all
the bits in the binary representation of the
number (swapping 0s for 1s and vice versa).

• The one’s complement of the number then


behaves like the negative of the original
number in some arithmetic operations.
8
One’s Complement(CONTD)
• To get one’s complement of a
number, simple invert each bit.
• For example,
• Find the one’s complement of
01001001.
0 1 0 0 1 0 0 1
• 1’s compl 1 0 1 1 0 1 1 0
9
Using one’s complement, subtract 15 from 26.
• Soln: 26 - 15 = + 26 + (-15)
• Binary of 26 = 0 1 1 0 1 0
• Binary of 15 = 0 0 1 1 1 1
• Inverse = 1 1 0 0 0 0
• Add 26 = + 0 1 1 0 1 0
• Overflow bit 1 0 0 1 0 1 0
• Add overflow bit + 1
• 0 0 1 0 1 12 =
1110 10
Two’s Complement
• To get the two’s complement, (i) add 1 to the
one’s complement
• For example: Find the two’s complement of 9.
• Soln:
• Decimal value of number: 9
• Binary value of number : 1 0 0 1
• One’s complement :011 0
• Two’s complement :011 1

11
Find the two Complement of +3

• +3= 0 0 1 1
• One’s comp. 1 1 0 0
• Add 1 + 1

two’s Comp. = 1 1 0 1

12
Classwork: Subtract 18 from 25 using two’s
complement
• 2510 - 1810 = 710

• Steps involved:
• (i) convert 18 to binary
• (ii) find the one’s complement of the binary
equivalent
• (iii) Add 1 to the one’s complement to change it
to two’s complement
• (iv) Add the result to 25 in binary
13
(i) Convert 18 to binary
2 18
2 9 r 0
2 4 r 1
2 2 r 0
2 1 r 0
0 r 1

18 = 100102
14
(ii) & (iii) Find the one’s complement of
18 = 100102 and Add 1

• Decimal 18
• Binary Equi.1 0 0 1 0
• One’s Compl. 0 1 1 0 1
• Add 1 + 1
• Two’s Compl. 0 1 1 1 0

15
(iv) Add the result to 25 in binary
25 = 0 1 1 0 0 1
• + 0 0 1 1 1 0
Parity Bit 1 0 0 1 1 1

•b 16
CHARACTER CODES

• Character code is a type of code


where group of binary is used to
represent each character. Character
includes digit (0-9), letter (A-Z) and
marks such as (semicolon, colon,
comma, quotation mark, blanks,
etc.)
17
• There are types of codes;
character code that are commonly
used include
- Binary coded decimal (BCD)
- American Standard Code for Information
Interchange (ASCII)
- Extended Binary Coded Decimal
Interchange Code (EBCDIC )
18

You might also like