0% found this document useful (0 votes)
128 views63 pages

EC 303 Chapter 3

The document discusses different number systems used in computing, including binary, decimal, hexadecimal, and octal. It explains that binary is used internally by computers, while hexadecimal and octal allow for more efficient representation of binary numbers. The key concepts of each number system are defined, including place values and how to perform arithmetic operations like addition, subtraction, multiplication and division. Negative numbers are also covered, explaining both one's complement and two's complement representation methods.

Uploaded by

PrevenaManiam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
128 views63 pages

EC 303 Chapter 3

The document discusses different number systems used in computing, including binary, decimal, hexadecimal, and octal. It explains that binary is used internally by computers, while hexadecimal and octal allow for more efficient representation of binary numbers. The key concepts of each number system are defined, including place values and how to perform arithmetic operations like addition, subtraction, multiplication and division. Negative numbers are also covered, explaining both one's complement and two's complement representation methods.

Uploaded by

PrevenaManiam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 63

BASIC COMPUTER ARCHITECTURE

&
NUMBERS SYSTEM
CHAPTER 3
What is this ?
Can you identify their functions?
BASIC COMPUTER ARCHITECTURE
&
NUMBERS SYSTEM
Understand Number Systems
Learning Outcomes
At the end of this presentation, the student
will be able :-
To describe the relationship between binary and
decimal number
To implement the arithmetic operation of binary
number
To describe the negative number
To use the complement number
To explain the octal, hexadecimal and floating
point number.

Number System Concepts
The study of number systems is useful to the
student of computing due to the fact that
number systems other than the familiar decimal
(base 10) number system are used in the
computer field.
Digital computers internally use the binary (base
2) number system to represent data and perform
arithmetic calculations.
The binary number system is very efficient for
computers, but not for humans.
Representing even relatively small numbers with
the binary system requires working with long
strings of ones and zeroes.
The hexadecimal (base 16) number system (often
called "hex" for short) provides us with a
shorthand method of working with binary
numbers.
One digit in hex corresponds to four binary digits
(bits), so the internal representation of one byte
can be represented either by eight binary digits
or two hexadecimal digits.
Less commonly used is the octal (base 8) number
system, where one digit in octal corresponds to
three binary digits (bits).
The binary, hexadecimal , and octal number
systems will be looked at in the following pages
RELATIONSHIP BETWEEN BINARY AND
DECIMAL NUMBER
OBE TECHNIQUE: OBJECTIVE TESTS
BINARY NUMBER
Base-two system.
Binary numbers use two digits (0,1).
Table 1 shows the weighting for the binary
number up to 3 decimal places and 2 decimal
places after the binary point (.).

8

Weights
2
2
2
1
2
0
. 2-
1
2
-2
4 2 1 . 0.5 0.25
Table 1 : Binary Weights
Converting binary to decimal
To express the value of a given binary number as its
decimal equivalent, we just need to sum the digits after
each has been multiplied by its associated weight.
Example 1:
Convert 110101
2
to decimal.
110101
2
= (1x 2
5
)+ (1x 2
4
)+ (0x 2
3
)+ (1x 2
2
)+
(0x 2
1
)+ (1x 2
0
)
= (1x32)+(1x16)+(0x8)+(1x4)+(0x2)+
(1x1)
= 32+16+0+4+0+1 = 53
9
Example 2:

Convert 0.1011
2
to decimal.
0.1011
2
= (1x 2
-1
)+ (0x 2
-2
)+ (1x 2
-3
)+ (1x 2
-4
)
=(1x0.5)+(0x0.25)+(1x0.125)+
(1x0.0625)
= 0.5+0+0.125+0.0625
= 0.6875
10
Example 3:

Convert 10.1011
2
to decimal.
10.1011
2
= (1x 2
1
)+ (0x 2
0
)+ (1x 2
-1
)+ (0x 2
-2
)+
(1x 2
-3
)+ (1x 2
-4
)
= (1x2)+ (0x1)+((1x0.5)+(0x0.25)+
(1x0.125)+(1x0.0625)
= 2 + 0 + 0.5+0+0.125+0.0625
= 2.6875
11
Converting decimal to binary
To convert decimal to binary use this approach:
i) Divide the decimal value by two and record
the remainder.
ii) Repeat step (i) until the decimal value is
equal to zero.
iii) The first remainder produced is the LSB in
the binary number and the last remainder is
the MSB.

12
Example 1:
Convert 18
10
to binary.


13
18
9
2
4
0
1
2
2
2
2
2 0
0
1
0
1
Therefore, 18
10
= 10010
2

Example 2:
Convert 0.3125
10
to binary.

0.3125 x 2 = 0.625 carry 0
0.625 x 2 = 1.25 carry 1
0.25 x 2 = 0.50 carry 0
0.50 x 2 = 1.00 carry 1
(*stop when the fractional part is all zero)

Therefore, 0.3125
10
= 0.0101
2
14
BINARY ARITHMETIC OPERATION
Binary Arithmetic Operation
Binary arithmetic operation involved:
Addition
Subtraction
Multiplication
Division

Binary Addition
The four basic rules for adding
binary digits are as follows:


17
0 + 0 = 0 carry 0
0 + 1 = 1 carry 0
1 + 0 = 1 carry 0
1 + 1 = 0 carry 1
Example 1:
Add the following binary number.
101
2

+ 010
2

111
2
Example 2:
Add the following binary number.
1010
2

+ 0111
2

10001
2
18
Binary Subtraction
The four basic rules for subtracting
binary digits are as follows:


19
0 0 = 0
1 1 = 0
1 0 = 1
0 1 = 1 borrow 1

Example 1:
Subtract the following binary number.
11
2

- 10
2

01
2
Example 2:
Subtract the following binary number.
101
2

- 011
2

010
2

20
Binary Multiplication
Multiplication is achieved by adding a list of
shifted
multiplicands according to the digits of the
multiplier
The four basic rules for subtracting binary
digits are as follows:


0 * 0 = 0
1 * 1 = 1
1 * 0 = 0
0 * 1 = 0

11 1 0 1 1 multiplicand (4 bits)
X 13 X 1 1 0 1 multiplier (4 bits)
-------- -------------------
33 1 0 1 1
11 0 0 0 0
______ 1 0 1 1
143 1 0 1 1
---------------------
1 0 0 0 1 1 1 1 Product (8 bits)

Binary Divison
Follow the same rules as in decimal division. For the sake of simplicity, throw
away the remainder.
Hands On
(a) Convert decimal to binary
1. 53
10

2. 0.81
10

(b) Convert binary to decimal
1. 111001
2

2. 00011010
2


c)
i. 1000100 010010
ii. 1010100 + 1100
iii. 110100 1001
iv. 11001 x 11
Answer
53
10
=> 53 / 2 = 26 remainder 1
26 / 2 = 13 remainder 0
13 / 2 = 6 remainder 1
6 / 2 = 3 remainder 0
3 / 2 = 1 remainder 1
1 / 2 = 0 remainder 1

= 110101
2
(6 bits)
= 00110101
2
(8 bits)
(note: bit = binary digit)
0.81
10
=> 0.81 x 2 = 1.62
0.62 x 2 = 1.24
0.24 x 2 = 0.48
0.48 x 2 = 0.96
0.96 x 2 = 1.92
0.92 x 2 = 1.84
= 0.110011
2
(approximately)


a)111001
2
(6 bits)
(1x2
5
) + (1x2
4
) + (1x2
3
) + (0x2
2
) +
(0x2
1
) + (1x2
0
)
= 32 + 16 + 8 + 0 + 0 + 1
= 57
10

b)00011010
2
(8 bits)
= 2
4
+ 2
3
+2
1

= 16 + 8 + 2
= 26
10

NEGATIVE AND COMPLEMENT
NUMBER
OBE TECHNIQUE: JIGSAW
29
Negative Integers Ones (1s) Complement
Computers generally use a system called
complementary representation to store
negative integers.
Two basic types - ones and twos
complement, of which 2s complement is
the most widely used.
The number range is split into two halves,
to represent the positive and negative
numbers.
Negative numbers begin with 1, positive
with 0.
30
Negative Integers Ones (1s) Complement
To perform 1s complement operation on a binary number,
replace 1s with 0s and 0s with 1s (ie Complement it!)
+6 represented by: 00000110
-6 represented by: 11111001
Advantages: arithmetic is easier (cheaper/faster electronics)
Fairly straightforward addition
Add any carry from the Most Significant (left-most) Bit
to Least Significant (right-most) Bit of the result
For subtraction
form 1s complement of number to be subtracted and then
add
Disadvantages : still two representations for zero
00000000 and 11111111 (in 8-bit representation)
31
Negative Integers Twos (2s) Complement
To perform the 2s complement operation on a
binary number
replace 1s with 0s and 0s with 1s (i.e. the ones
complement of the number)
add 1
+6 represented by: 00000110
-6 represented by: 11111010
Advantages:
Arithmetic is very straightforward
End Around Carry is ignored
only one representation for zero (00000000)
32
Negative Integers Twos (2s) Complement
Twos Complement
To convert an integer to 2s complement
Take the binary form of the number
00000110 (6 as an 8-bit representation)
Flip the bits: (Find 1s Complement)
11111001
Add 1
11111001
+1
11111010 (2s complement of 6)
Justification of representation: 6+(-6)=0?
00000110 (6)
+11111010 (2s complement of 6)
100000000 (0)
33
Negative Integers Twos (2s) Complement
Properties of Twos Complement
The 2s comp of a 2s comp is the original number
00000110 (6)
11111010 (2s comp of 6)
00000101
+1
00000110 (2s comp of 2s comp of 6)
The sign of a number is given by its MSB
The bit patterns:
00000000 represents zero
0nnnnnnn represents positive numbers
1nnnnnnn represents negative numbers
34
Negative Integers Twos (2s) Complement
Addition
Addition is performed by adding corresponding bits
00000111 ( 7)
+00000101 (+5)
00001100 (12)
Subtraction
Subtraction is performed by adding the 2s complement
Ignore End-Around-Carry
00001100 (12)
+11111011 (-5)
100000111 ( 7)

35
Negative Integers Twos (2s) Complement
Interpretation of Negative Results
00000101 ( 5)
+11110100 (-12)
11111001 ( )

Result is negative
MSB of result is 1 so it is a negative number in 2s complement
form
Negative what?
Take the 2s comp of the result to find out since the 2s comp
of a 2s comp is the original number
Negative 7
the 2s complement of 11111001 is 00000111 or 7
10

36
Comparing the signed number systems
Here are all the 4-bit numbers in
the different systems.
Positive numbers are the same in
all three representations.
Signed magnitude and ones
complement have two ways of
representing 0. This makes things
more complicated.
Twos complement has
asymmetric ranges; there is one
more negative number than
positive number. Here, you can
represent -8 but not +8.
However, twos complement is
preferred because it has only one
0, and its addition algorithm is
the simplest.
Decimal S.M. 1s comp. 2s comp.
7 0111 0111 0111
6 0110 0110 0110
5 0101 0101 0101
4 0100 0100 0100
3 0011 0011 0011
2 0010 0010 0010
1 0001 0001 0001
0 0000 0000 0000
-0 1000 1111
-1 1001 1110 1111
-2 1010 1101 1110
-3 1011 1100 1101
-4 1100 1011 1100
-5 1101 1010 1011
-6 1110 1001 1010
-7 1111 1000 1001
-8 1000

Exercise
Get the representation of ones
complement (6 bit) for the following
numbers:

i) +7
10
ii) 10
10
Solution:

(+7) = 000111
2

Solution:

(+10)
10
= 001010
2

So,
(-10)
10
= 110101
2

Get the representation of ones
complement (6 bit) for the following
numbers:

i) +7
10
ii) 10
10
Others Number System
OCTAL NUMBER
Base-eight system.
Octal numbers use eight digits (0,1,2,3,4,5,6,7).
Table 3 shows the weighting for the octal number up
to 3 decimal places and 2 decimal places after the
octal point (.).
40

Weights
8
2
8
1
8
0
. 8
-1
8
-2
64 8 1 . 0.125 0.015625
Table 3 : Octal Weights
Converting octal to decimal
Example 1:

Convert 237.04
8
to decimal.
237.04
8
= (2x 8
2
)+(3x8
1
)+(7x8
0
)+ (0x8
-1
)+
(4x8
-2
)
= (2x64)+(3x8)+(7x1)+(0x0.125)+
(4x0.015625)
= 128+24+7+0+0.625
= 159.0625
41
Converting decimal to octal
Example 1:
Convert 359 to octal.

8 359
8 44 7
8 5 4
0 5

Therefore, 359 = 547
8


42
Example 2:
Convert 0.312510 to binary.

0.3125 x 8 = 2.50 carry 2
0. 5 x 8 = 4.00 carry 4
(*stop when the fractional part is all zero)

Therefore, 0.312510 = 0.24
8

43
Converting octal to binary
One (1) octal digit can be represented by three digit
binary number, as shown in Table 4.







Table 4: Octal and Binary Number
44
Octal Digit Binary Digit
0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111
Example 1:
Convert 13
8
to binary.
1 3
001
2
011
2

Therefore, 13
8
= 001011
2

Example 2:
Convert 37.12
8
to binary.
3 7 . 1 2
011
2
111
2
. 001
2
010
2

Therefore, 13
8
= 011111.001010
2

45
Converting binary to octal
Break the binary digits into groups of three starting from
LSB.
It may be necessary to add a zero as the MSB in order to
complete a grouping of three digits.
Example 1:
Convert 010111
2
to octal.

010
2
111
2

2 7
Therefore, 010111
2
= 27
8


46
Octal Arithmetic
a. Octal Addition
- Example 1: - Example 2:

356
8
+ 124
8
733
8
+ 74
8


3 5 6
8
7 3 3
8

+ 1 2 4
8
+ 7 4
8

5 0 2
8
1 0 2 7
8


47
b. Octal Subtraction
- Example 1: - Example 2:

1523
8
- 364
8
145
8
- 64
8


1 5 2 3
8
1 4 5
8

- 3 6 4
8
- 6 4
8

1 1 3 7
8
6 1
8


48
HEXADECIMAL NUMBER
Base-sixteen system.
Hexadecimal numbers use sixteen digits
(0,1,2,3,4,5,6,7,8,9, A, B, C, D, E, F).
Table 5 shows the weighting for the hexadecimal
number up to 3 decimal places and 2 decimal places
after the hexadecimal point (.).
49

Weight
s
16
2
16
1
16
0
. 16
-1
16
-2
256 16 1 . 0.0625 0.0039
Table 5 : Hexadecimal Weights
Converting hexadecimal to decimal
Example 1:

Convert 356
16
to decimal.

356
16
= (3x 16
2
)+(5x16
1
)+(6x16
0
)


= (3x256)+(5x16)+(6x1)
= 768+80+6
= 854
50
Example 2:

Convert AF2
16
to decimal.

AF2
16
= (Ax16
2
)+(Fx16
1
)+(2x16
0
)


= (10x256)+(15x16)+(2x1)
= 2560+240+2
= 2802
51
Converting decimal to hexadecimal
Example 1:
Convert 650 to hexadecimal.

16 650
16 40 10
16 2 8
0 2

Therefore, 650 = 28A
16


52
Converting hexadecimal to binary
One (1) hexadecimal digit can be represented by four digit
binary number, as shown in Table 5.








Table 5: Hexadecimal and Binary Number

53
Hexadecimal
Digit
Binary Digit
8 1000
9 1001
A 1010
B 1011
C 1100
D 1101
E 1110
F 1111
Hexadecimal
Digit
Binary Digit
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
Example 1:
Convert 38
16
to binary.
3 8
0011
2
1000
2

Therefore, 38
16
= 00111000
2

Example 2:
Convert FB17
16
to binary.
F B 1 7
1111
2
1011
2
0001
2
0111
2

Therefore, FB17
16
= 1111101100010111
2

54
Converting binary to hexadecimal
Break the binary digits into groups of four starting
from LSB.
It may be necessary to add a zero as the MSB in
order to complete a grouping of four digits.
Example 1:
Convert 1010111
2
to hexadecimal.
0101
2
0111
2

5 7
Therefore, 1010111
2
= 57
16

55
Hexadecimal Arithmetic
56
a. Hexadecimal Addition
- Example 1: - Example 2: - Example 3:

23
16
+ 16
16
2B
16
+ 84
16
DF
16
+ AC
16


2 3
16
2 B
16
D F
16

+ 1 6
16
+ 8 4
16
+ A C
16

3 9
16
A F
16
1 8 B
16


57
b. Hexadecimal Subtraction

- Example 1: - Example 2:

75
16
21
16
84
16
2A
16


7 5
16
8 4
16

- 2 1
16
- 2 A
16

5 4
16
5 A
16


Floating Point
In computing, floating point describes a system for
representing numbers that would be too large or too small to
be represented as integers.
The base for the scaling is normally 2, 10 or 16.
For example, in a decimal floating-point system with three
digits, the multiplication that humans would write as
0.12 0.12 = 0.0144
would be expressed as
(1.2 10
1
) (1.2 10
1
) = (1.44 10
2
).
In a fixed-point system with the decimal point at the left, it
would be
0.120 0.120 = 0.014.

58
OBE TECHNIQUE:GIVE ONE GET ONE
BCD CODE (Binary Coded Decimal)
One of the most widely used representations of numerical
data.
BCD 8421 code represents each decimal digit (0 through 9) by
4 bit binary equivalents.




The biggest decimal digit represented by BCD 8421 code is 9.
The six code combination are invalid in the BCD 8421 are
1010
2
, 1011
2
, 1100
2
, 1101
2
, 1110
2
and 1111
2
.



59
2 4 7
0010 0100 0111
Decimal number
BCD 8421
Representation
To express any decimal number in BCD 8421, simply replace
each decimal digit with the appropriate 4-bit code.
Example 1:
Convert each of the following decimal number to BCD 8421.
a) 875
8 7 5
1000 0111 0101

b) 35
3 4
0001 0100


60
61
Example 2:
Convert each of the following BCD 8421 to decimal numbers.

a) 10000110
BCD 8421

1000 0110
8 6

b) 001101010001
BCD 8421


0011 0101 0001
3 5 1


62
Example 3:
Convert the following BCD 8421 to binary number.
10010110
BCD 8421

i) Convert BCD 8421 to decimal number
1001 0110
9 6 , therefore 10010110 = 96
ii) Convert decimal number to binary number
96
2 48 0
2 24 0
2 12 0
2 6 0
2 3 0 , therefore 10010110
BCD 8421
= 1100000
2

2 1 1
0 1
63
Example 4:
Convert the following binary number to BCD 8421.
1001010
2

i) Convert binary number to decimal number
1001010 = (1x 2
6
)+ (0x 2
5
)+ (0x 2
4
)+ (1x 2
3
)+ (0x 2
2
)+
(1x 2
1
)+ (0x 2
0
)
= 64 + 0 + 0 + 8 + 0 + 2 + 0
= 74
ii) Convert decimal number to BCD 8421

7 4
0111 0100

Therefore 1001010
2
= 01110100
BCD 8421

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy