Chap 2
Chap 2
Organization &
Architecture
Ch t 2
Chapter 2: N
Number
b S System
t
37 ÷ 2 = 18 balance 1 (LSB)
18 ÷ 2 = 9 balance 0
9÷ 2 = 4 balance 1
4÷ 2 = 2 balance 0
2÷ 2 = 1 balance 0
1÷ 2 = 0 balance 1 (
(MSB)
)
1001102
= (1 X 25) + (0 X 24) +(0 X 23) +(1 X 22) +
(1 X 21) + (0 X 20)
= 32 + 0 + 0 + 4 + 2 + 0
= 3810
5638
= (5 X 82) + (6 X 81) + (3 X 80)
= 320
3 0 + 48 + 3
= 37110
563.228
563
= (5 X 82) + (6 X 81) + (3 X 80) + (2 X 8-1)
= 371 + ((2 X 1/8))
= 371 + 1/4
= 371.2510
21 ÷ 16 = 1 balance 5 (LSB)
1 ÷ 16 = 0 balance 1 (MSB)
Now, 0.25
X 2
(MSB) 0 0.50
X 2
(LSB)
( ) 1 1.00
So, 0.2510 = 0.012
21.2510 = 10101 . 01002
= 15.416
Numeric Conversion
(Base16 to Base10)
E516
= (E X 161) + (5 X 160)
= (14 X 16) + (5 X 1)
= 224 + 5
= 22910
Example 2
Addition and Subtraction
(Octal Base8)
Example 2
Addition and Subtraction
(Hexadecimal Base16)
Example 2
Numeric Conversion
~ Exercise
E i ~
1. Perform the addition and subtraction for the following
g
binary numbers:
a) 10 + 111010
b) 10001011 – 100111
c) 1000 + 1011
d) 11000 – 1111
a) B677 + CE79
b) 21BA + ADD
c) 9A3B + FACE
d) A5 - 17
e) 7AC - 3B1
f) FA51 - A76
Signed and Unsigned
N
Numbers
b
Binary numbers either signed or unsigned
CPU performs arithmetic and comparison
operations for both type equally well, without
knowing which type it’s
it s operating on
on.
An unsigned numbers :
numbers with only positive values
for 8-bit storage location : store unsigned integer
value between 0 - 255
for 16-bit storage
g location : store unsigned
g integer
g
value between 0 - 65535
Unsigned number can be converted directly
to binary numbers and processed without
any special care
Signed and Unsigned
N
Numbers
b
For negative numbers, there are several
ways used d to
t representt it in
i bi
binary fform,
depending on the process take place :
i. Sign
Sign-and-magnitude
and magnitude representation
ii. 1’s complement representation
iii. 2’s complement representation
Sign and Magnitude
In daily usage, signed integers are
represented
t d by
b a plus
l or minus
i sign
i and da
value.
In the computer, the uses of 0’s
0 s and 1’s
1 s take
place.
0 : plus ( positive)
1 : minus (negative)
The leftmost bit in a binary number is
considered the sign bit
bit.
The remaining (n-1) bits are used for
g
magnitude.
Sign and Magnitude
Example 1 :
+ 0100101 0000000000000001 0111111111111111
(+37) (+1) (+32767)
- 1100101 1000000000000001 1111111111111111
(-37) (-1) (-32767)
Example 2 :
What is the sign-and-magnitude
g g
representation of the decimal numbers –31
and +31 if the basic unit is a byte ?
Sign and Magnitude
Example 3 :
What is the decimal equivalent value of the
sign-and -magnitude binary sequence
10111001 ?
Addition of 2 numbers in sign-and-
magnitude :
using the usual conventions of binary arithmetic
if both have same sign : magnitude are added and
the same signg copied
p
if the sign different : number that has smaller
magnitude is subtracted from the larger one
Sign and Magnitude
Example 4 :
What is the decimal value of the sum of the
binary numbers 10110011 and 00010110 if
they are represented in sign-and-magnitude?
sign and magnitude?
Assume that the basic unit is the byte.
1’s Complement
C
Conversion
i
In base 2,, the largest
g digit
g is 1.
The 1’s complement is performed simply by
changing every 0 1 and every 1 0.
also known as inversion
Most popular among computer manufacturers
since it does not present any of the problems
of the sign-and-magnitude or 1’s complement.
Positive numbers : using similar procedure as
sign-and-magnitude
2’s Complement
C
Conversion
i
Given n bits, the range of numbers that can
b represented
be t d iin 2’
2’s complement
l 2n+1 to
t iis –2 t
2n-1 –1
Example 1 :
Wh t is
What i the
th 2’s
2’ complement
l t representation
t ti off -23?
23?
Example 2 :
What is the decimal positive value of the 2’s
2s
complement number 111000112 ?
2’s Complement
C
Conversion
i
Perform the following operation in 8-bit 2’s
complement
complement.
2’s Complement
C
Conversion
i
Exercise
2’s Complement
C
Conversion
i
Exercise
IEEE Floating Point
R
Representation
t ti
2pproblems with integers;
g ; they y can’t express
p
fractions & the range number is limited to the
number of bits used.
A efficient
An ffi i t way off storing
t i fractions
f ti floating
fl ti
point method
involves splitting the fraction into two parts, an
exponent and a mantissa
Computer industry agreed upon a standard for
the storage of floating point numbers
the IEEE 754 standard; uses 32 bits of memory
(single precision) or 64 bits (double precision)
IEEE Floating Point
R
Representation
t ti
IEEE short real : 32 bits ((Exponent
p system
y =
excess 127)
Total number
off bits
b : 1 8 23
Sign Biased Mantissa
exponent (fraction)
Exponent = 7
Get the biased
Biased exponent = 127 + y = 127 + 7 = 134
exponent (ii)
= 1000 01102 (8 bits)
Convert to =0100 0011 0001 1001 1100 0000 0000 0000 ((4 bit–hexa))
hexadecimal = 4319C000h
IEEE Floating Point
R
Representation
t ti
• Convert C2F0000016 in IEEE floating
gppoint
format to the decimal number.
= 1.1112 x 26
Put into 1.xxxx X 2y
= 1111000
G t the
Get th sign
i Si = -ve (1)
Sign
Get the mantissa & Significand = 111
the significand Mantissa = 111 0000 0000 0000 0000 0000 (23 bits)
Convert to binary 1100 0010 1111 0000 0000 0000 0000 0000
In hexadecimal = C2F00000 h
Thank you