Lesson 01 - Numbering Systems
Lesson 01 - Numbering Systems
LESSON 01
NUMBERING SYSTEMS
25 = 32
2–4 = 0.0625 20 = 1
26 = 64
2–3 = 0.125 21 = 2
27 = 128
2–2 = 0.25 22 = 4
28 = 256
2–1 = 0.5 23 = 8
29 = 512
20 = 1 24 = 16
210 = 1,024
128 64 32 16 8 4 2 1
1 1 0 0 0 1 0 1
COM211 - Computer Architecture 1
Converting from Binary to Denary
= 128 + 16 + 4 + 1
= 149 COM211 - Computer Architecture 1
Converting from Binary to Denary
A denary number, such as 107, can be converted into binary as follows:
Example
2). Then, starting from the left, ‘take out’ the values in the column headings, if possible:
2048 cannot be taken out of 1359 so that column contains a ‘0’:
2048 1024 512 256 128 64 32 16 8 4 2 1
0
3.) 1024 can be taken out of 1359 so that column contains a ‘1’;
this leaves 1359 – 1024 = 329:
2048 1024 512 256 128 64 32 16 8 4 2 1
0 1
4). 256 can be taken out of 329 so that column contains a ‘1’; this leaves 329 – 256 = 73:
2048 1024 512 256 128 64 32 16 8 4 2 1
0 1 0 1
5). keep repeating the above process until the whole number has been converted to pure
binary:
2048 1024 512 256 128 64 32 16 8 4 2 1
0 1 0 1 0 1 0COM2110- Computer
1 Architecture
1 11 1
Alternative approach -
Conversion of the decimal value 1359 to
base two:
◦ 0 A B C D Hexadecimal
◦ 0000 1010 1011 1100 1101 Binary
COM211 - Computer Architecture 1
Converting Binary to Hexadecimal Numbers
Example:
Convert 1011001010 (base 2) to
Hexadecimal:
◦ Solution:
◦ Step 1: Add two bits to the left of the binary
number 1011001010 so that it contains 12 bits.
Step 2:
◦ Separate the binary value into groups of four bits
giving: 0010 1100 1010.
Step 3:
◦ Convert each group to the appropriate hexadecimal
digits which gives: 2CA.
NEXT
LESSON 2B
EXAMPLE:
Convert 1000 110112 to Decimal number
EXAMPLE:
2 4 8 16 34 70 140 282
x2
ADD
Therefore 1000110112 = 28310
COM211 - Computer Architecture 1
BINARY TO DECIMAL CONVERSION
EXAMPLE:
Convert the binary fraction 0.11010001 2 to
Decimal number
ADD /2
Therefore 0.110100012 = 0.8164062510
COM211 - Computer Architecture 1
DECIMAL TO BINARY CONVERSION
The Divide and Remainder Algorithm for
the Integer part:
◦ 1. Divide number by 2 and record remainder
Note:
Note:
LESSON 2C
Subtractions
[Lesson 2 continues]
r's Complement = rn – N
r's Complement:
Example 1:
10's complement of 830594 = 169406
Example 2:
2's complement of 10110010110101 is
01001101001011
Page 56
COM211 - Computer Architecture 1
Substraction of Unsigned Numbers:
M - N (in base r)
M is minuend, N is subtrahend
To perform subtraction:
M – N = M + (rn - N) = M - N + rn
Page 57
November 22, 2 COM211 - Computer Architecture 1
Substraction of Unsigned Numbers:
Page 58
November 22, 2 COM211 - Computer Architecture 1
Binary Substraction using 2's complement:
Example:
110100010101 – 10110001
110100010101
+ 111101001111
= 1 110001100100 Discard carry:
Ans = 110001100100
November 22, 2 Page 59
023 COM211 - Computer Architecture 1
DATA REPRESENTATION
SIGNED NUMBERS
Signed-magnitude representation,
Signed-1's complement representation,
Signed-2's complement representation,
November 22, 2 Page 60
COM211 - Computer Architecture 1
023
SIGNED NUMBERS
The left-most bit is always used as the sign bit in
signed numbers.
If a signed number is stored in 16-bit
register, the register holds 15 significant bits,
plus a sign bit.
A 16-bit register can hold signed numbers
between the ranges -215 and +(215 - 1)
◦ Sign-Magnitude representation
◦ 1's Complement representation
◦ 2's Complement representation
In sign-magnitude representation:
◦ The msb is the sign bit, with value of 0 for positive integers
and 1 for negative integers.
Example 1:
Addition of Two Positive Integers:
Suppose that n = 8 bits,
◦ 65d + 5d = 70 (decimal)
COM211 - Computer Architecture 1
2’s Complement Addition
Example 2: Subtraction is treated as Addition of a
Positive and a Negative Integers:
◦ 1] 15 + (-15)
◦ 15 = 0000 1111
◦ +15 = 0000 1111
◦ 30 = 0001 1110 OK
◦ 2] 127 + 1
◦ 127 = 0111 1111
◦ + 1= 0000 0001
◦ - 128 = (0) 1000 0000 (0) 1 Overflow
◦ 3] -15 + (-15)
◦ -15 = 1111 0001
◦ + -15 = 1111 0001
◦ - 30 = (1) 1110 0010 (1) 1 OK
◦ 4] -127 + (- 2)
◦ -127 = 1000 0001
◦ + -2 = 1111 1110
◦ - 129 = (1) 0111 1111 (1) 0 Overflow
Example:
From 0 to 15
Example:
From -7 to 7
Example:
With 4 bits, the range is from –(23 ) to (23 – 1)
From -8 to 7
-128 64 32 16 8 4 2 1
0 0 0 1 0 0 1 0
-18
-128 64 32 16 8 4 2 1
1 1 1 0 1 1 1 0
Note:
The range of integers that can be
represented with one byte is from -128 to
+127
-128 64 32 16 8 4 2 1
1 0 0 0 0 0 0 0 = -128
0 1 1 1 1 1 1 1 = +127
Step 2: = -128 + 64 + 16 + 4 + 1
= -43
Example 2: Convert the sign + magnitude number
11001100 to Denary:
- 64 32 16 8 4 2 1
1 1 0 0 1 1 0 0
◦ 4000h: = +16384.
NEXT
"If
the number is negative the H.O. byte of the 16 bit
number contains 0FFh;
Eight Bits Sixteen Bits Thirty-two Bits
CONTINUE WITH SLIDE ON FLOATI
NG POINTS
◦ 0 (0000 0000),
◦ 1 (0000 0001),
◦ -1 (1111 1111),
◦ 0 (0000 0000),
◦ +1 (0000 0001),
◦
◦ -128 (1000 0000),
◦ -1 (1000 0001),
◦ +1 (0000 0001),
◦ -1 (1111 1110),
◦ +1 (0000 0001),
THANK YOU
The most significant bit is the sign bit (S), with 0 for
negative numbers and 1 for positive numbers.
Then:
S = 1
E = 1000 0001
m = 011 0000 0000 0000 0000 0000
In the normalized form, the actual fraction is
normalized with an implicit leading 1 in the
form of F = 1.m.
Normalized Form
Example, suppose that the 32-bit pattern is 1
1000 0001 011 0000 0000 0000 0000 0000,
m = mantissa
Then: F = 1.m
In this example, the actual fraction is
F = 1.011 0000 0000 0000 0000 0000
= 1 + 1×2-2 + 1×2-3
= 1.375d.
= - 1.01112 x 22
S=1 e=2
Therefore E = 2 + 127 = 129 = 1000 0001 2
m = 011 1000 0000 0000 0000 0000
Hence, the number represented is:
N = 1 1000 0001 0111 0000 0000 0000 0000 000
S E m
Note: Better presentation
EXAMPLE 3:
What is the Single Precision (32 bits)
floating point representation for 19.625 in
hexadecimal
Solution:
19.62510 = 10011.1012
2 19 Carry Overs
2 9 R1 .625 x 2
2 4 R1 1 .250 x 2
2 2 R0 0 .500 x 2
2 1 R0 1 .00 x 2
2 0 R1
S = 0 (Positive)
e = 2 Therefore E = 127 + 2 = 129 = 1000 0001
m = 0111 0000 0000 0000 0000 000
54.624 = 36.A h
= - 1.1 0110 1010 x 25 = 0011 0110 . 1010 b
S = 1 (Negative)
e = 5 Therefore E = 127 + 5 = 132 = 1000 0100
m = 1011 0101 0000 0000 0000 0000
16 313 . 125 x 16
= 0001 0011 1001. 0010 16 19 R 9
16 1 R 3
2
0
000 x 16
000
16 0 R 1
313.124 = 139.2 h
S = 0 (Positive)
e = 8 Therefore E = 127 + 8 = 135 = 1000 0111
m = 0011 1001 0010 0000 0000 0000
STOP
THANK YOU