> 9=L?<;:(
/0DTimes New RomanDv0(
0DTahomaew RomanDv0(
0h" DWingdingsRomanDv0(
0h0DArial NarrowanDv0(
0T"@DArialNarrowanDv0(
0h"PDCourier NewanDv0(
0T1a.
@n?" dd@ @@``ph
D
nn
CG
CGCG&'?@ VXCG+/
CGVX&'?@
! 9AktVXCGCGCGon
& +,*0
3$*00!!+1258
''7B"#$
$%#"()< .0e0eA@A5%8c8c
?1d0u0@Ty2 NP'p<'p@A)BCDE? @!ff+h@8uʚ;mNʚ;g41d1dv0ppp@<4!d!d`
0LlE<4dddd`
0LlEg4:d:dv0p]pp<4BdBd`
0LlEZ___PPT94 ?%O=tKSigned Numbers<CS208jSigned NumbersrUntil now we've been concentrating on unsigned numbers. In real life we also need to be able represent signed numbers ( like: 12, 45, +78).
A signed number MUST have a sign (+/). A method is needed to represent the sign as part of the binary representation.
Two signed number representation methods are:
Sign/magnitude representation
Twoscomplement representation6 2= 2&9Sign/Magnitude Representation
In sign/magnitude (S/M) representation, the leftmost bit of a binary code represents the sign of the value:
0 for positive,
1 for negative;
The remaining bits represent the numeric value. o
"
3
',GG;GGGGG2Gg,oDSign/Magnitude RepresentationTo compute negative values using Sign/Magnitude (S/M) representation:
Begin with the binary representation of the positive value
Then flip the leftmost zero bit.
J;
" " #
" " IG,GGG#GgSign/Magnitude Representation5Ex 1. Find the S/M representation of 610
/8Z2pZF%Sign/Magnitude Representation1 Ex 2. Find the S/M representation of 7010
pZ2
p}2
G#GOGGMSign/Magnitude Representation2 Ex 3. Find the S/M representation of 3610
.pZ2
p}2
G$GOGGSign/Magnitude Representation
"Try It Yourself
NAnswers035 = 00100011
60 = 10111100
101 = 11100101`1$ $$
$$ $Problems with Sign/Magnitude
>Two s Complement Representation (Another method used to represent negative numbers (used by most modern computers) is two s complement.
The leftmost bit STILL serves as a sign bit:
0 for positive numbers,
1 for negative numbers.
4hGG/G4Gg,>Two s Complement Representation (To compute negative values using Two s Complement representation:
Begin with the binary representation of the positive value
Complement (flip each bit  if it is 0 make it 1 and visa versa) the entire positive number
Then add one.CZ
" ZGG0GGg>Two s Complement Representation (2Ex 1. Find the 8bit two s complement representation of 610
Step 1: Find binary representation of the positive value in 8 bits
610 = 0000011027!
!!C
!
!$! >Two s Complement Representation (z Ex 1 continued Step 2: Complement the entire positive value
Positive Value: 00000110
Complemented: 11111001r{( !a>Two s Complement Representation (7So: 610 = 111110102
(in 8bit 2's complement form)8EG$O$G$O$G$EEGgE>Two s Complement Representation (Ex 2. Find the 8bit two s complement representation of 2010
Step 1: Find binary representation of the positive value in 8 bits
2010 = 000101002
20 is positive, so STOP after step 1!0U
G8GOGGCGOGG!O!G!'G;>Two s Complement Representation (vEx 3. Find the 8bit two s complement representation of 8010
Step 1: Find binary representation of the positive value in 8 bits
8010 = 010100002
80 is negative, so continue& 9E!!<>Two s Complement Representation (v Ex 3 Step 2: Complement the entire positive value
Positive Value: 01010000
Complemented: 10101111w< !=>Two s Complement Representation (8So: 8010 = 101100002
(in 8bit 2's complement form)9GGOGOGGgOTry It Yourself
#Answers73 = 10110111
45 = 00101101
97 = 10011111`.$
$$
$$ $
>Two s Complement Representation (2 Alternate method  replaces previous steps 23
F3ZG1GG>Two s Complement Representation (`Ex 1: Find the Two s Complement of 7610
n1ZG$GOGG>Two s Complement Representation (Step 2: Find first one bit, from loworder (right) end, and complement the pattern to the left.
01001100
(left complemented) > 10110100
Z G WGgG G G G G g Gg>>Two s Complement Representation (Ex 2: Find the Two s Complement of 7210
Step 1: Find the 8 bit binary representation of the positive value.
7210 = 010010002 <G GOGG<GgGOGOg?>Two s Complement Representation (`Ex 3: Find the Two s Complement of 2610
1ZG!GG O GG@>Two s Complement Representation (Ex 3, Step 2: Find first one bit, from loworder (right) end, and complement the pattern to the left.
00011010
(left complemented) > 11100110
ZG
EWEe)EEEeG>Two s Complement Representation (
PTry It Yourself
%Answers36 = 11011100
66 = 10111110
15 = 00001111`.$
$$
$$ $76Two s Complement to Decimal(Ex 1: Find the decimal equivalent of the
8bit 2 s complement value 111011002
dRZH86Two s Complement to Decimal(~Ex 1, Step 2: Find first one bit, from loworder (right) end, and complement the pattern to the left.
11101100G
G$WEeG$G(G$:6Two s Complement to Decimal(Ex 1, Step 3: Determine the numeric value:
000101002 = 16 + 4 = 2010
So: 111011002 = 2010 (8bit 2's complement form)^((($$$$$$(($$$$A6Two s Complement to Decimal(Ex 2: Find the decimal equivalent of the
8bit 2 s complement value 010010002
dRZHF6Two s Complement to Decimal(~Ex2, Step 3: Determine the numeric value:
010010002 = 64 + 8 = 7210
So: 010010002 = 7210 (8bit 2's complement form)* ($$$$$$($$$$$D6Two s Complement to Decimal(Ex 3: Find the decimal equivalent of the
8bit 2 s complement value 110010002
RZ?B6Two s Complement to Decimal(~Ex 3, Step 2: Find first one bit, from loworder (right) end, and complement the pattern to the left.
11001000~GWGgG$G((C6Two s Complement to Decimal(Ex 3, Step 3: Determine the numeric value:
001110002 = 32 + 16 + 8 = 5610
So: 110010002 = 5610 (8bit 2's complement form) ($$$$$$$$$$$&S/M problems solved with 2s complement''(
>Two s Complement Representation (Biggest reason two s complement used in most systems today?
The binary codes can be added and subtracted as if they were unsigned binary numbers, without regard to the signs of the numbers they actually represent.
*>Two s Complement Representation (]For example, to add +4 and 3, we simply add the corresponding binary codes, 0100 and 1101:
F^Z[GgGTwos Complement Representation(DLikewise, to subtract +7 from +3:
0011 (+3)
 0111 (+7)
1100 (4)
NOTE: A phantom 1 was borrowed from beyond the leftmost position.Z"GgGgGGGGgGgEQTry It Yourself
'Answer*33 = 11011111
+17 = + 00010001
11110000
11110000 is negative
Convert to 00010000 = 16
So answer = 16
(which IS the result of 33 + 17)
) #>Two s Complement Representation ( Summary  Benefits of Twos Complements:
Addition and subtraction are simplified in the two scomplement system,
0 has been eliminated, replaced by one extra negative value, for which there is no corresponding positive number. F) P P()Valid RangesFor any integer data representation, there is a LIMIT to the size of number that can be stored.
The limit depends upon number of bits available for data storage.J=7*Unsigned Integer RangesRange = 0 to (2n 1)
where n is the number of bits used to store the unsigned integer.
Numbers with values GREATER than (2n 1) would require more bits. If you try to store too large a value without using more bits, OVERFLOW will occur.ckcccc:cc!cckcmcC(Unsigned Integer RangeszExample: On a system that stores unsigned integers in 16bit words:
Range = 0 to (216 1)
= 0 to 65535
Therefore, you cannot store numbers larger than 65535 in 16 bits.Ey!FaaiaaaaCaADy+Signed S/M Integer RangesRange = (2(n1) 1) to +(2(n1) 1)
where n is the number of bits used to store the sign/magnitude integer.
Numbers with values GREATER than +(2(n1) 1) and values LESS than (2(n1) 1) would require more bits. If you try to store too large/too small a value without using more bits, OVERFLOW will occur.w
aiaiaaacc@ccc$c$"cckccckcvcb@,S/M Integer RangesExample: On a system that stores unsigned integers in 16bit words:
Range = (215 1) to +(215 1)
= 32767 to +32767
Therefore, you cannot store numbers larger than 32767 or smaller than 32767 in 16 bits.F%Ecc c k c k c c c c c Yc,D.Two s Complement RangesRange = 2(n1) to +(2(n1) 1)
where n is the number of bits used to store the twos complement signed integer.
Numbers with values GREATER than +(2(n1) 1) and values LESS than 2(n1) would require more bits. If you try to store too large/too small a value without using more bits, OVERFLOW will occur.{c k
c k c c c ccIccc$c$"cckccckcwcC ..Two s Complement RangesExample: On a system that stores unsigned integers in 16bit words:
Range = 215 to +(215 1)
= 32768 to +32767
Therefore, you cannot store numbers larger than 32767 or smaller than 32768 in 16 bits.F%Fcc
c k c k c c c c c YcD/Try It YourselfWhat range of values can be represented by:
a) a 6bit unsigned number
b) a 6bit sign/magnitude number
c) a 6bit 2's complement number
(Answers on NEXT slide)%0ZK+ccccccccccccccG0AnswersRUnsigned = 0 to (26 1)
= 0 to 63
S/M = (25 1) to +(25 1)
= 31 to +31
2 s Comp = 25 to +(25 1)
= 32 to +31z!aiaaaa
aiaiaaaaaiaiaaaC(i@1"Using Ranges for Validity CheckingOnce you know how small/large a value can be stored in n bits, you can use this knowledge to check whether you answers are valid, or cause overflow.
Overflow can only occur if you are adding two positive numbers or two negative numbers
@
2"Using Ranges for Validity Checking6Ex 1:
Given the following 2 s complement equations in 5 bits, is the answer valid?
11111 (1) Range =
+11101 (3) 16 to +15
11100 (4) VALID
T
J"Using Ranges for Validity Checking>Ex 2:
Given the following 2 s complement equations in 5 bits, is the answer valid?
10111 (9) Range =
+10101 (11) 16 to +15
01100 (20) INVALID
T
!!!4Try It Yourself~Perform the following 6bit 2 s complement addition. Indicate if overflow occurs. Check your answers by converting to decimal (remember, if the leftmost bit is ONE, the value is negative).
v%Z%Z+ccccC5AnswersH 0 1 1 0 0 1 (+25)
+0 1 0 0 0 0 (+16)
1 0 1 0 0 1 (+41) out of
(invalid) range (over 31)
1 1 0 1 1 1 (9)
+1 1 1 0 0 1 (7)
1 1 0 0 0 0 (16) OKAY
#####$'#####'/pP: ` 33PP` 3333` ___MMM` 13` 333fpKNāvI` j@v۩ῑH` Q_{>?" dd@,?n<d@ `7 `2@`7``2 t?" dd@% @@``PR @ ` `p>>nf
(
<@,"
Ba
T/d"
Ba
<2"U_
Ba
T 5d">&
Ba
N`"P
Ba
<Њ"p
Ba
Cx@?d?"bUv
Ba
6X "U
T Click to edit Master title style!
!$
0ܒ "
RClick to edit Master text styles
Second level
Third level
Fourth level
Fifth level!
S
6 "@
b*c
6, "@`
d* c
6蠉 "`
d* cB
s*h ? 3333 Blends
5

0
(
T +
"+bb P@
#"Dwoh
s*"PP
Bd" P@bb P
0
#"Nyh
s*"P
Bd"P
0z
<" a*h
s*"
f?d?"+)
< ?"pP
T Click to edit Master title style!
!
0 " `
W#Click to edit Master subtitle style$
$
6 "`p
f*"g
6HZ "`p
h*$g
6^ "`
h*$gB
s*h ? 33330@x "(
x
x
0P P
V*b
x
0
X*b
d
x
c$ ?0P
x
0
@
RClick to edit Master text styles
Second level
Third level
Fourth level
Fifth level!
S
x
68 P
V*b
x
6
X*b
H
x 0h9 ? ̙33P Pd (
d
d
0 P#
\*
d
0` #
^*
d
6 P
\*
d
6
^*H
d 0h9 ? ̙33 d
0(
d
x
d
c$g
pP
x
d
c$g
`
H
d
0h ? ˽"i6ffff
`\(
x
c$
U
c$
@`<$0
H
0h ? [RIȺ*=zdj
p <(
~
s*@
U
~
s*0
P0
H
0h ? [RIȺ*=zdj
R(
~
s* É
U
s*p
p
"p`PpH
0h ? [RIȺ*=zdjC
(
~
s*LK
U
s*L
G<$D0
0
,$D0
fF So: 610 = 100001102
(in 8bit sign/magnitude form)G8Z2gggg o g o g ge#
0+ ,$D0
m Step 2: If the number you want to represent is negative, flip leftmost bit
10000110R8Z20Z2 gg+e
eeeegg!g
0D9 P
,$D0
RF Step 1: Find binary representation using 8 bits 610 = 000001102 Gxx2
gg'egogg!o!gH
0h ? [RIȺ*=zdjd
( (
( ~
( s*x
U
( s*X
`<$D0
'
(
0%
,$D0
Step 2: If the number you want to represent is negative, flip left most bit
01000110 (positive  no flipping) pZ2
gg(eee!geeO
(
0D ,$D0
fF Step 1: Find binary representation using 8 bits 7010 = 010001102 Gpx2
gg)egogg!o!g!g!
(
0Z 0,$D0
o; So: 7010 = 010001102
(in 8bit sign/magnitude form)<pZ2
gggg o g o g geeH
( 0h ? [RIȺ*=zdj
l
/(
l
~
l
s*p
U
l
s*P
@0<$D0
l
0Xj 00
,$D0
2\Step 2: If the number you want to represent is negative, flip left most bit
10100100]pZ2
gg(eeeg!g
l
0{ p@` ,$D0
QG Step 1: Find binary representation using 8 bits 3610 = 001001002 Hpx2
gg)egogg!o!g!
l
0
,$D0
p< So: 3610 = 101001002
(in 8bit sign/magnitude form)=pZ2
gggg o g o g geeH
l
0h ? [RIȺ*=zdj
%XP
t (
t "
t
BG/*1?4 ,$D0B
t
H1?
,$D
0
t
`(gֳgֳ1pp?
;Y,$D0
VSign bit:
0 positive
1 negative,
bf!b
bf
bB
t
H1? @,$D
0?
t
`Hgֳgֳ1pp?
,$D0
{131 remaining bits for magnitude (i.e. the value).2
bbr
t
`H)jJ? @ ,$D
0
t
T@1?
,$D0
c32bit example:
0 000 0000 0000 0000 0000 0000 0000 1001
1 000 0000 0000 0000 0000 0000 0000 1001
R
bd!'``d(``HH
t
`,1?&,$D
0
8+9
`
t
`H1? ,$D
0
89
`B
t
TD!jJ?\@\,$D
0B
t
TD!jJ?L @L ,$D
0x
t c$
U
H
t 0h ? 333###GGGggg
1(
x
c$H
U
y
0J @
uConvert the following decimal numbers to 8bit sign/magnitude representation:
35
60
101
(Answers on NEXT slide)rN ( Nbb$b$fH
0h ? ˽"i6ffff
p
<(
p
~
p
s*O
U
~
p
s*P
@p
H
p
0h ? ˽"i6ffff3.
%02 G(
/
T`8c8c?*0,$D0
w% Two different representations for 0!6&
c%e2
s*8c?]b,$D0
Tgֳgֳ?,$D0
D0000$
g
Tgֳgֳ?"L,$D
0
D0111$
g
Tgֳgֳ?A
,$D0
D0011$
g
Thgֳgֳ?+ , ,$D0
D1011$
g
Tgֳgֳ? ,$D0
D1111$
g
TP gֳgֳ?.
F,$D0
D1110$
g
Tt!gֳgֳ?V~ ,$D0
D1101$
g
T($gֳgֳ?A! ,$D0
D1100$
g
Tdgֳgֳ?
g
,$D
0
D1010$
g
T8fgֳgֳ?
,$D0
D1001$
g
Tigֳgֳ?
L,$D0
D1000$
g
Tkgֳgֳ?
/
,$D 0
D0110$
g
TLogֳgֳ?
3
,$D0
D0101$
g
Tygֳgֳ?N
m
,$D0
D0100$
g
T@}gֳgֳ?V,$D0
D0010$
g
Tgֳgֳ?l
D,$D0
D0001$
gl 'be
1 O
,$D0
TЄgֳgֳ?JbP
6,$D0
B+0$
g!
T,gֳgֳ?
,$D0
B+1$
g!
Tgֳgֳ?{+,$D0
B+2$
g!
Ttgֳgֳ?O#,$D0
B+3$
g!
Tugֳgֳ?k ,$D0
B+4$
g!
T5gֳgֳ?{ y
,$D0
B+5$
g!
T8gֳgֳ?
z,$D0
B+6$
g!
T<;gֳgֳ?'
e,$D0
B+7$
g!l fbp
2
,$D0
T8gֳgֳ?
p,$D
0
B0$
g
TȰgֳgֳ?
,$D0
B1$
g
T$gֳgֳ? a
,$D0
B2$
g
Tgֳgֳ?ftLH ,$D
0
B3$
g
!
T8gֳgֳ?fDL,$D0
B4$
g
"
Tgֳgֳ?,$D0
B5$
g
#
Tgֳgֳ?5 ,$D0
B6$
g
$
Tgֳgֳ?0
b6,$D0
B7$
g
%
T<1?
! P
,$D0
`$Inner numbers:Binary representation %
%cH
&
T`1?*,$D0
TSeven Positive Numbers and Positive Zero +
+cH
'
T1?j
,$D0
TSeven Negative Numbers and Negative Zero +
+c
)
T8c8c?JAP,$D0
f Two discontinuities6
ce3z pP
*
Q
J
,$D02
+
TjJ? @
,$D02
,
TjJ?pP,$D0z pP

Q
J
,$D02
.
T3jJ?
,$D02
/
T3jJ?pP,$D0x
0 c$\M
U
H
0h ? 333###GGGggg(
0 h(
0 ~
0 s*P
U
0 s*0.
=p<$0
H
0 0h ? [RIȺ*=zdj
0h R(
h ~
h s*'
U
h s*l
@Pp`
"p`PpH
h 0h ? [RIȺ*=zdj(
@4 h(
4 ~
4 s*d
U
4 s*
<$0
H
4 0h ? [RIȺ*=zdj(
P8 h(
8 ~
8 s*
U
8 s*
Pp<$0
H
8 0h ? [RIȺ*=zdj
` 9(
~
s*
U
s*
<$0
&x h_7
0P @p,$D0
Ex 1, Step 3: Add one to complemented value
(complemented) > 11111001
(add one) > + 1
11111010V gg "g g g g g g g g g g "g g !g ! h_7H
0h ? [RIȺ*=zdj
pL
3(
L
~
L
s*l
U
L
s*L
Pp<$0
L
0
,$D0
/7So: 2010 = 000101002
(in 8bit 2's complement form)8 ggogoggg h_7H
L
0h ? [RIȺ*=zdj(
$
h(
$
~
$
s*,b
U
$
s*c
pPp<$0
H
$
0h ? [RIȺ*=zdj(
(
h(
(
~
(
s*)
U
(
s*,
<$0
H
(
0h ? [RIȺ*=zdj
,
:(
,
~
,
s*l1
U
,
s*:
@<$0
&x h_7
,
0D! @@,$D0
Ex 3, Step 3: Add one to complemented value
(complemented) > 10101111
(add one) > + 1
10110000V gg"gggggg
gggg!gg!g! h_7H
,
0h ? [RIȺ*=zdjZ
t
(
t
~
t
s*`
U
t
0
Convert the following decimal numbers to 8bit 2 s complement representation:
73
45
97
(Answers on NEXT slide)PN 0 Nbb$fH
t
0h ? ˽"i6ffff
<(
~
s*
U
~
s*
0
H
0h ? ˽"i6ffff
< ^(
< ~
< s*F
U
~
< s*4G
l `
< P
,$D0
<
0T `
P~Step 2: Scanning the positive binary representation from right to left,
find first one bit, from loworder (right) end
0ZggAegee"eB
< B
#lDԔ??pPP:
<
0L P,$D0
Step 3: Complement (flip) the remaining bits to the left.
00000110
(left complemented) > 11111010
}0Zgg,eeee7gggggH
< 0h ? [RIȺ*=zdjJ
@ (
@ ~
@ s*
U
~
@ s*
p
F
@
0m ,$D0
ZStep 1: Find the 8bit binary representation of the positive value.
7610 = 010011002
&Y (g g ;ggg g g o g o g gH
@ 0h ? [RIȺ*=zdj
skD (
D ~
D s*T
U
~
D s*؉
`
D
0 PP,$D0
+9So: 7610 = 101101002
(in 8bit 2's complement form): g g o g o g g gH
D 0h ? [RIȺ*=zdjb
0
(
0
~
0
s*
U
0
s*
VPp<$0
2
0
0X P ,$D0
jSteps 23: 72 is positive, so STOP after step 1!
So: 7210 = 010010002
(in 8bit 2's complement form)k <
g(gggg o g o g ggH
0
0h ? [RIȺ*=zdj`
4
(
4
~
4
s*7t
U
t
~
4
s*88t
pPPt
\
4
0 `,$D0
ZStep 1: Find the 8bit binary representation of the positive value.
2610 = 000110102
<Y (g g ;ggg g g o g g !o !g !gH
4
0h ? [RIȺ*=zdj
sk 8
(
8
~
8
s*At
U
t
~
8
s*Bt
`t
8
06 PP,$D0
+9So: 2610 = 111001102
(in 8bit 2's complement form): g g o g o g g gH
8
0h ? [RIȺ*=zdj
%{0
(
"
BG/*1?<J ,$D0B
H1?H Fvh
,$D
0~
`\4gֳgֳ1pp?P
,$D0
.Sign bit:
0 > positive
1 > negativep/
cg!cg
cB
H1?x
,$D
0
`g g g g g H
H
0h ? [RIȺ*=zdjp
@
(
@
~
@
s*8t
U
t
~
@
s*t
ppt
l
@
0 P
P
,$D0
<(left complemented) 00111000j g$$((H
@
0h ? [RIȺ*=zdj
2*D
(
D
~
D
s*t
U
t
D
ct0e0e
@P<$0t
H
D
0h ? ˽"i6ffff
%$./ ,(
#
T)8c8c?
`
,$D0
k Only one discontinuity now4
ae2
s*8c?& <,$D0
Tl.gֳgֳ?;Q,$D0
D0000$
g
TD3gֳgֳ?
],$D
0
D0111$
g
T;gֳgֳ?SH ,$D0
D0011$
g
TL>gֳgֳ?{
2
,$D0
D1011$
g
TAgֳgֳ?^,$D0
D1111$
g
TDgֳgֳ?
,$D0
D1110$
g
THgֳgֳ? M],$D0
D1101$
g
TKgֳgֳ?
H ,$D0
D1100$
g
TOgֳgֳ?Y
6,$D
0
D1010$
g
TRgֳgֳ?,f
,$D0
D1001$
g
TVgֳgֳ?g,$D0
D1000$
g
TYgֳgֳ?Dj,$D 0
D0110$
g
T]gֳgֳ?}
4,$D0
D0101$
g
T`gֳgֳ? <U
,$D0
D0100$
g
Tdgֳgֳ?],$D0
D0010$
g
Tggֳgֳ?
;,$D0
D0001$
g
l
. \v
R
,$D0
Tdkgֳgֳ?)S,$D0
B+0$
g!
Tngֳgֳ?=7,$D0
B+1$
g!
TPrgֳgֳ?ZKE,$D0
B+2$
g!
Tugֳgֳ?oi,$D0
B+3$
g!
T?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{}~/0DTimes New Roman4dv0(
0DTahomaew Roman4dv0(
0T" DWingdingsRoman4dv0(
0T0DArial Narrowan4dv0(
0T"@DArialNarrowan4dv0(
0T"PDCourier Newan4dv0(
0T1a.
@n?" dd@ @@``x<ZDocumentSummaryInformation8Arial NarrowanDdv0(
0T"@DArialNarrowanDdv0(
0T"PDCourier NewanDdv0(
0T1a.
@n?" dd@ @@``x4^
nn
CG
CGCG&'?@ VXCG+/
CGVX&'?@
! 9AktVXCGCGCGon
& +,*0
3$*00!!+128
''7B"#$
$#"()< .EFGHIJKLMNOPST
UVWXYZ[\]^_`abcfghijklmn0e0eA@A5%8c8c
?1d0u0@Ty2 NP'p<'p@A)BCDE? @!ff+h@8uʚ;mNʚ;g41d1dv0pppp@<4!d!d`
0,lE<4dddd`
0,lEg4:d:dv0pp]pp<4BdBd`
0,lE&7___PPT94 ?%O=KSigned Numbers<
jSigned NumbersrUntil now we've been concentrating on unsigned numbers. In real life we also need to be able represent signed numbers ( like: 12, 45, +78).
A signed number MUST have a sign (+/). A method is needed to represent the sign as part of the binary representation.
Two signed number representation methods are:
Sign/magnitude representation
Twoscomplement representation6 2= 2&9Sign/Magnitude Representation
In sign/magnitude (S/M) representation, the leftmost bit of a binary code represents the sign of the value:
0 for positive,
1 for negative;
The remaining bits represent the numeric value. o
"
3
',GG;GGGGG2Gg,oDSign/Magnitude RepresentationTo compute negative values using Sign/Magnitude (S/M) representation:
Begin with the binary representation of the positive value
Then flip the leftmost zero bit.
J;
" " #
" " IG,GGG#GgSign/Magnitude Representation5Ex 1. Find the S/M representation of 610
/8Z2pZF%Sign/Magnitude Representation1 Ex 2. Find the S/M representation of 7010
pZ2
p}2
G#GOGGMSign/Magnitude Representation2 Ex 3. Find the S/M representation of 3610
.pZ2
p}2
G$GOGGSign/Magnitude Representation
Problems with Sign/Magnitude
>Two s Complement Representation (Another method used to represent negative numbers (used by most modern computers) is two s complement.
The leftmost bit STILL serves as a sign bit:
0 for positive numbers,
1 for negative numbers.
4hGG/G4Gg,>Two s Complement Representation (To compute negative values using Two s Complement representation:
Begin with the binary representation of the positive value
Complement (flip each bit  if it is 0 make it 1 and visa versa) the entire positive number
Then add one.CZ
" ZGG0GGg>Two s Complement Representation (2Ex 1. Find the 8bit two s complement representation of 610
Step 1: Find binary representation of the positive value in 8 bits
610 = 0000011027!
!!C
!
!$! >Two s Complement Representation (z Ex 1 continued Step 2: Complement the entire positive value
Positive Value: 00000110
Complemented: 11111001r{( !a>Two s Complement Representation (7So: 610 = 111110102
(in 8bit 2's complement form)8EG$O$G$O$G$EEGgE>Two s Complement Representation (Ex 2. Find the 8bit two s complement representation of 2010
Step 1: Find binary representation of the positive value in 8 bits
2010 = 000101002
20 is positive, so STOP after step 1!0U
G8GOGGCGOGG!O!G!'G;>Two s Complement Representation (vEx 3. Find the 8bit two s complement representation of 8010
Step 1: Find binary representation of the positive value in 8 bits
8010 = 010100002
80 is negative, so continue& 9E!!<>Two s Complement Representation (v Ex 3 Step 2: Complement the entire positive value
Positive Value: 01010000
Complemented: 10101111w< !=>Two s Complement Representation (8So: 8010 = 101100002
(in 8bit 2's complement form)9GGOGOGGg
>Two s Complement Representation (2 Alternate method  replaces previous steps 23
F3ZG1GG>Two s Complement Representation (`Ex 1: Find the Two s Complement of 7610
n1ZG$GOGG>Two s Complement Representation (Step 2: Find first one bit, from loworder (right) end, and complement the pattern to the left.
01001100
(left complemented) > 10110100
Z G WGgG G G G G g Gg>>Two s Complement Representation (Ex 2: Find the Two s Complement of 7210
Step 1: Find the 8 bit binary representation of the positive value.
7210 = 010010002 <G GOGG<GgGOGOg?>Two s Complement Representation (`Ex 3: Find the Two s Complement of 2610
1ZG!GG O GG@>Two s Complement Representation (Ex 3, Step 2: Find first one bit, from loworder (right) end, and complement the pattern to the left.
00011010
(left complemented) > 11100110
ZG
EWEe)EEEeG>Two s Complement Representation (
76Two s Complement to Decimal(Ex 1: Find the decimal equivalent of the
8bit 2 s complement value 111011002
dRZH86Two s Complement to Decimal(~Ex 1, Step 2: Find first one bit, from loworder (right) end, and complement the pattern to the left.
11101100G
G$WEeG$G(G$:6Two s Complement to Decimal(Ex 1, Step 3: Determine the numeric value:
000101002 = 16 + 4 = 2010
So: 111011002 = 2010 (8bit 2's complement form)^((($$$$$$(($$$$A6Two s Complement to Decimal(Ex 2: Find the decimal equivalent of the
8bit 2 s complement value 010010002
dRZHF6Two s Complement to Decimal(~Ex2, Step 3: Determine the numeric value:
010010002 = 64 + 8 = 7210
So: 010010002 = 7210 (8bit 2's complement form)* ($$$$$$($$$$$D6Two s Complement to Decimal(Ex 3: Find the decimal equivalent of the
8bit 2 s complement value 110010002
RZ?B6Two s Complement to Decimal(~Ex 3, Step 2: Find first one bit, from loworder (right) end, and complement the pattern to the left.
11001000~GWGgG$G((C6Two s Complement to Decimal(Ex 3, Step 3: Determine the numeric value:
001110002 = 32 + 16 + 8 = 5610
So: 110010002 = 5610 (8bit 2's complement form) ($$$$$$$$$$$&S/M problems solved with 2s complement''(
>Two s Complement Representation (Biggest reason two s complement used in most systems today?
The binary codes can be added and subtracted as if they were unsigned binary numbers, without regard to the signs of the numbers they actually represent.
*>Two s Complement Representation (]For example, to add +4 and 3, we simply add the corresponding binary codes, 0100 and 1101:
F^Z[GgGTwos Complement Representation(DLikewise, to subtract +7 from +3:
0011 (+3)
 0111 (+7)
1100 (4)
NOTE: A phantom 1 was borrowed from beyond the leftmost position.Z"GgGgGGGGgGgE>Two s Complement Representation ( Summary  Benefits of Twos Complements:
Addition and subtraction are simplified in the two scomplement system,
0 has been eliminated, replaced by one extra negative value, for which there is no corresponding positive number. F) P P()Valid RangesFor any integer data representation, there is a LIMIT to the size of number that can be stored.
The limit depends upon number of bits available for data storage.J=7*Unsigned Integer RangesRange = 0 to (2n 1)
where n is the number of bits used to store the unsigned integer.
Numbers with values GREATER than (2n 1) would require more bits. If you try to store too large a value without using more bits, OVERFLOW will occur.ckcccc:cc!cckcmcC(Unsigned Integer RangeszExample: On a system that stores unsigned integers in 16bit words:
Range = 0 to (216 1)
= 0 to 65535
Therefore, you cannot store numbers larger than 65535 in 16 bits.Ey!FaaiaaaaCaADy+Signed S/M Integer RangesRange = (2(n1) 1) to +(2(n1) 1)
where n is the number of bits used to store the sign/magnitude integer.
Numbers with values GREATER than +(2(n1) 1) and values LESS than (2(n1) 1) would require more bits. If you try to store too large/too small a value without using more bits, OVERFLOW will occur.w
aiaiaaacc@ccc$c$"cckccckcvcb@,S/M Integer RangesExample: On a system that stores unsigned integers in 16bit words:
Range = (215 1) to +(215 1)
= 32767 to +32767
Therefore, you cannot store numbers larger than 32767 or smaller than 32767 in 16 bits.F%Ecc c k c k c c c c c Yc,D.Two s Complement RangesRange = 2(n1) to +(2(n1) 1)
where n is the number of bits used to store the twos complement signed integer.
Numbers with values GREATER than +(2(n1) 1) and values LESS than 2(n1) would require more bits. If you try to store too large/too small a value without using more bits, OVERFLOW will occur.{c k
c k c c c ccIccc$c$"cckccckcwcC ..Two s Complement RangesExample: On a system that stores unsigned integers in 16bit words:
Range = 215 to +(215 1)
= 32768 to +32767
Therefore, you cannot store numbers larger than 32767 or smaller than 32768 in 16 bits.F%Fcc
c k c k c c c c c YcD1"Using Ranges for Validity CheckingOnce you know how small/large a value can be stored in n bits, you can use this knowledge to check whether you answers are valid, or cause overflow.
Overflow can only occur if you are adding two positive numbers or two negative numbers
@
2"Using Ranges for Validity Checking6Ex 1:
Given the following 2 s complement equations in 5 bits, is the answer valid?
11111 (1) Range =
+11101 (3) 16 to +15
11100 (4) VALID
T
J"Using Ranges for Validity Checking>Ex 2:
Given the following 2 s complement equations in 5 bits, is the answer valid?
10111 (9) Range =
+10101 (11) 16 to +15
01100 (20) INVALID
T
!!!NFloating Point Numbers<
OFloating Point NumbersNow you've seen unsigned and signed integers. In real life we also need to be able represent numbers with fractional parts (like: 12.5 & 45.39). ` KpPFloating Point NumbersIn the decimal system, a decimal point (radix point) separates the whole numbers from the fractional part
Examples:
37.25 ( whole = 37, fraction = 25/100)
123.567
10.12345678
`uB)QFloating Point Numbers For example, 37.25 can be analyzed as:
101 100 101 102
Tens Units Tenths Hundredths
3 7 2 5
37.25 = (3 x 10) + (7 x 1) + (2 x 1/10) + (5 x 1/100)
l&GgGOGOGOGOo"GgGG6GgGRBinary Equivalence The binary equivalent of a floating point number can be determined by computing the binary representation for each part separately.
: 2(2SNFractional Part Multiplication Method(( 4 In the binary representation of a floating point number the column values will be as follows:
& 25 24 23 22 21 20 . 21 22 23 24 &
& 32 16 8 4 2 1 . 1/2 1/4 1/8 1/16&
& 32 16 8 4 2 1 . .5 .25 .125 .0625&
^33339<, TNFractional Part Multiplication Method(( Ex 1. Find the binary equivalent of 0.25
Step 1: Multiply the fraction by 2 until the fractional part becomes 0 .25
x 2
0.5
x 2
1.0
ZZG!G
GGG)GCGgGGgGGGGGgCGGCG(UNFractional Part Multiplication Method(( Ex 2. Find the binary equivalent of 0.625
Step 1: Multiply the fraction by 2 until the fractional part becomes 0 .625
x 2
1.25
x 2
0.50
x 2
1.0
PZZG!GGGG)GCG gGGg
GGGGGg
CGGGGGGGGCG5VHFractional Part Subtraction Method%% Start with the column values again, as follows:
& 20 . 21 22 23 24 25 26&
& 1 . 1/2 1/4 1/8 1/16 1/32 1/64&
& 1 . .5 .25 .125 .0625 .03125 .015625&
"3333
25WWHFractional Part Subtraction Method%% Starting with 0.5, subtract the column values from left to right. Insert a 0 in the column if the value cannot be subtracted or 1 if it can be. Continue until the fraction becomes .0
Ex 1.
.25 .5 .25 .125 .0625
 .25 .0 1
.0
Z@ZGG33GGG
GGgG33XBinary Equivalent of FP numberEx 2. Convert 37.25, using subtraction method.
64 32 16 8 4 2 1 . .5 .25 .125 .0625
26 25 24 23 22 21 20 . 21 22 23 24
0G*GgC G33G!G33O33G33O33G33O33G33O33G33O33G33O33G33O33G33G!G33O33G33O33G33O33G33O33 CGWYYBinary Equivalent of FP numberPEx 3. Convert 18.625, using subtraction method.
64 32 16 8 4 2 1 . .5 .25 .125 .0625
26 25 24 23 22 21 20 . 21 22 23 24
1 0 0 1 0 1 0 1
18 .625
 16  .5
2 .125
 2  .125
0 01ZxZ0ZxZG,GgC G33G!G33O33G33O33G33O33G33O33G33O33G33O33G33O33G33G!G33O33G33O33G33O33G33O33/GG'
'X\Problem storing binary formWe have no way to store the radix point!
Standards committee came up with a way to store floating point numbers (that have a decimal point) P]"IEEE Floating Point Representation##$Floating point numbers can be stored into 32bits, by dividing the bits into three parts:
the sign, the exponent, and the mantissa.
Z 2.(2`
%^"IEEE Floating Point Representation##$The first (leftmost) field of our floating point representation will STILL be the sign bit:
0 for a positive number,
1 for a negative number.
]3[EGG2G$g$g$6\_Storing the Binary FormHow do we store a radix point?
 All we have are zeros and ones&
Make sure that the radix point is ALWAYS in the same position within the number.
Use the IEEE 32bit standard
the leftmost digit must be a 1
BT!`Solution is Normalization% Every binary number, except the one corresponding to the number zero, can be normalized by choosing the exponent so that the radix point falls to the right of the leftmost 1 bit.
37.2510 = 100101.012 = 1.0010101 x 25
7.62510 = 111.1012 = 1.11101 x 22
0.312510 = 0.01012 = 1.01 x 22z&Z/94
!a"IEEE Floating Point Representation##$
The second field of the floating point number will be the exponent.
The exponent is stored as an unsigned 8bit number, RELATIVE to a bias of 127.
Exponent 5 is stored as (127 + 5) or 132
132 = 10000100
Exponent 5 is stored as (127 + (5)) or 122
122 = 01111010 )  :F
)! !bTry It YourselfkHow would the following exponents be stored (8bits, 127biased):
210
28
(Answers on next slide)
B% ) % BaaiaieaAcAnswers 210
exponent 10 8bit
bias +127 value
117 01110101
28
exponent 8 8bit
bias +127 value
135 10000111 !)!%!!!%
!%!)!%!!!%
!%d"IEEE Floating Point Representation##$The mantissa is the set of 0 s and 1 s to the left of the radix point of the normalized (when the digit to the left of the radix point is 1) binary number.
Ex: 1.00101 X 23
(The mantissa is 00101)
GGAG
GFGG"G"!G"O"O"EG$e2Decimal Floating Point toIEEE standard Conversion"32 " Ex 1: Find the IEEE FP representation of 40.15625
Step 1.
Compute the binary equivalent of the whole part and the fractional part. (i.e. convert 40 and .15625 to their binary equivalents) G3GgG\GGGGGG Cf2Decimal Floating Point toIEEE standard Conversion33 40 .15625
 32 Result: .12500 Result:
8 101000 .03125 .00101
 8 .03125
0 .0
So: 40.1562510 = 101000.001012
ZGgGGFFGGGF GG
GGGGGg
GgGgFF N F F N Ff'g2Decimal Floating Point toIEEE standard Conversion33 Step 2. Normalize the number by moving the decimal point to the right of the leftmost one.
101000.00101 = 1.0100000101 x 25
]'GVGgG
G G G O o G g h2Decimal Floating Point toIEEE standard Conversion33 Step 3. Convert the exponent to a biased exponent
127 + 5 = 132
And convert biased exponent to 8bit unsigned binary:
13210 = 100001002
ZG,Gg GGJGOGGOgGgi2Decimal Floating Point toIEEE standard Conversion33 Step 4. Store the results from steps 13:
Sign Exponent Mantissa
(from step 3) (from step 2)
0 10000100 01000001010000000000000
~G&G9G0Gg j2Decimal Floating Point toIEEE standard Conversion33 Ex 2: Find the IEEE FP representation of 24.75
Step 1. Compute the binary equivalent of the whole part and the fractional part.
24 .75
 16 Result:  .50 Result:
8 11000 .25 .11
 8  .25
0 .0
So: 24.7510 = 11000.112
ZfZ 8Z2ZG'GGGgGMGgGgGGG GgGG
GGgGGGgGg '', k2Decimal Floating Point toIEEE standard Conversion33 Step 2.
Normalize the number by moving the decimal point to the right of the leftmost one.
11000.11 = 1.100011 x 24
GXGgEMeEel3Decimal Floating Point toIEEE standard Conversion. 42 Step 3. Convert the exponent to a biased exponent
127 + 4 = 131
==> 13110 = 100000112
Step 4. Store the results from steps 13
Sign Exponent mantissa
1 10000011 1000110..0
@2ZZZG+Gg!GOGOgGG?GGgGo4IEEE standard to Decimal Floating Point Conversion. 53 Do the steps in reverse order
In reversing the normalization step move the radix point the number of digits equal to the exponent:
If exponent is positive, move to the right
If exponent is negative, move to the leftfUGgfGGGGGG GGGGp4IEEE standard to Decimal Floating Point Conversion. 53 Ex 1: Convert the following 32bit binary number to its decimal floating point equivalent:
Sign Exponent Mantissa
1 01111101 010..0
6]ZBZGXGgGgGgGGgGgGgq5IEEE standard to Decimal Floating Point Conversion.. 63 Step 1: Extract the biased exponent and unbias it
Biased exponent = 011111012 = 12510
Unbiased Exponent: 125 127 = 2
G+GgGEMEEME&EE$'Vr5IEEE standard to Decimal Floating Point Conversion.. 63 Step 2: Write Normalized number in the form:
1 . ____________ x 2 
For our number:
1. 01 x 2 2
wZG(GGGOGGGGOggGgks4IEEE standard to Decimal Floating Point Conversion. 53 *Step 3: Denormalize the binary number from step 2 (i.e. move the decimal and get rid of (x 2n) part):
0.01012 (negative exponent move left)
GWGOGgGG O G GGG$ t4IEEE standard to Decimal Floating Point Conversion. 53 Ex 2: Convert the following 32 bit binary number to its decimal floating point equivalent:
Sign Exponent Mantissa
0 10000011 10011000..0
[7GZGGGGGGgGGgEeu5IEEE standard to Decimal Floating Point Conversion.. 63 Step 1: Extract the biased exponent and unbias it
Biased exponent = 10000112 = 13110
Unbiased Exponent: 131 127 = 4
G+GgGEMEEME&EEE'Vv5IEEE standard to Decimal Floating Point Conversion.. 63 tStep 2: Write Normalized number in the form:
1 . ____________ x 2 
For our number:
1.10011 x 2 4
uG'GEEEMEEEG$
G$O$o$w4IEEE standard to Decimal Floating Point Conversion. 53 Step 4: Convert binary number to the FP equivalent (i.e. Add all column values with 1s in them)
11001.1 = 16 + 8 + 1 +.5
= 25.510a/(G[GG"G G$O$G$/pPp d
(
d
x
d
c$g
pP
H
d
0h ? ˽"i6ffffv&P
(
~
s*j
`j
H
0h ? ˽"i6ffff
\T`
(
~
s*j
U
j
s*O
@
<$0j

0PT
p,$0
\Called Floating Point numbers.
You will learn the IEEE 32bit floating point representation.Z]0ZKggHgH
0h ? [RIȺ*=zdj
p
<(
~
s*b
U
~
s*e
pP
H
0h ? [RIȺ*=zdj
R(
~
s*k
U
s*q
p
"pH
0h ? [RIȺ*=zdjm
(
~
s*x
U
s*
PpP
"pS
0d p,$D0
1) For the whole part:
Use subtraction or division method previously learned.
2) For the fractional part:
Use the subtraction or multiplication method (to be shown next)
0Z27 0Z2b8Z2gg g7gg
gKgcpH
0h ? [RIȺ*=zdj
R(
~
s*
U
j
s*#
@ `j
"pH
0h ? [RIȺ*=zdj
og
(
~
s*t
U
s*'#
P<$D0
"py
0># ,$D0
Step 2: Collect the whole parts in forward order. Put them after the radix point
. .5 .25 .125 .0625
. 0 1
n0Z 8ZeKeg33g!g33g!g33 gcg,ZpH
0h ? [RIȺ*=zdj
(
~
s*Hd
U
s*#
0<$D0d
"p
0`I# ,$D0
Step 2: Collect the whole parts in forward order. Put them after the radix point
. .5 .25 .125 .0625
. 1 0 1
n0Z&8ZeKeg33g!g33g!g33gcg>ZpH
0h ? [RIȺ*=zdj
X(
~
s*pW#
U
#
s*xY#
#
(hpH
0h ? [RIȺ*=zdj
R(
~
s*9
U
s*#
p
"pH
0h ? [RIȺ*=zdj
0(
~
s*#
U
d
s*#
0#
"p
0# @`,$D0
n1 0 0 1 0 1
37
 32 5
 4
1
1
0 &&0ZI8Zf
dedddde dndd dfP0&p
0t @ ,$D0
_ . 0 1
.25
 .25
.0
(0ZP8Zff
dedddedededfP0po
`#??0(",$D0
37.2510 = 100101.012
z0Zfnfn`H
0h ? [RIȺ*=zdj
:2
(
~
s*T#
U
#
s*x
0#
"pp
`??,$D0
18.62510 = 10010.1012
z0Zfnfn`H
0h ? [RIȺ*=zdj
0
<(
~
s*\
U
~
s*
P0
H
0h ? ˽"i6ffff
@
4(
~
s*xO
U
~
s*
@
`jJ??
`B
`DjJ??
`B
`DjJ??
pp`B
@
fDjJ??0
B
@
fDjJ??0 0
B
@
fDjJ??0
P
T$??
51 2
T??p
H2 9 2
T??P
e110 322 22H
0h ? [RIȺ*=zdj
P
<(
~
s*
U
~
s*
p
H
0h ? [RIȺ*=zdj(
`
h(
~
s*8
U
s*x
p<$0
H
0h ? [RIȺ*=zdj
p
:(
~
s*\
U
~
s*
@0
z0e0eB[CDEXF(@jJ8c8c
?1d0u0@Ty2 NP'p<'p@A)BCDE?[I5F*HO\c_
qqclZiHcHc)L5@
P J
z0e0eB[CDEXF(@8c8c8c
?1d0u0@Ty2 NP'p<'p@A)BCDE?[I5F*HO\c_
qqclZiHcHc)L5@
P@
z0e0eB[CDEXF(@8c8c8c
?1d0u0@Ty2 NP'p<'p@A)BCDE?[I5F*HO\c_
qqclZiHcHc)L5@ H
0h ? [RIȺ*=zdj(
h(
~
s*
U
s*
pPp <$0
H
0h ? [RIȺ*=zdj\
(
~
s*
U
s߿0e0e
x
H
0h ? ˽"i6ffff
0(
(
~
s*
U
x
c$@
@pp
B
ZD??
H
0h ? ˽"i6ffff
ia
(
~
s*
U
~
s*A
P{
0
PP,$D0
!qThe mantissa is stored in a 23 bit field, so we add zeros to the right side and store:
00101000000000000000000
~W0Z0ZWggg!gH
0h ? [RIȺ*=zdj
<(
~
s*쇾
U
~
s*g
p
H
0h ? [RIȺ*=zdj
P(
~
s*t
U
~
s*
@ `
B
ZD??
B
ZD??
H
0h ? [RIȺ*=zdjf
(
~
s*\w
U
~
s*
b
:0e0eBCDE(F@Ԕ8c8c
?1d0u0@Ty2 NP'p<'p@A)BCDE?
Pp8P0 @ `H
0h ? [RIȺ*=zdj
<(
~
s*
U
~
s*
p
H
0h ? [RIȺ*=zdj
<(
~
s*
U
~
s*w
H
0h ? [RIȺ*=zdj
JB
(
~
s*dŲ
U
~
s*
B
ZD??
B
ZD??B
ZD??H
0h ? [RIȺ*=zdjf
(
~
s*ݲ
U
~
s*4
pPp
b
:0e0eBCDE(F@Ԕ8c8c
?1d0u0@Ty2 NP'p<'p@A)BCDE?
Pp8P0 @ pPH
0h ? [RIȺ*=zdj
0<(
~
s*X
U
~
s*
pP`
H
0h ? [RIȺ*=zdj
`<(
~
s*
U
~
s*
H
0h ? [RIȺ*=zdj
p<(
~
s*_
U
~
s*@d
H
0h ? [RIȺ*=zdj
<(
~
s*x
U
~
s*X}
@P`
H
0h ? [RIȺ*=zdj
PH(
~
s*H
~
s*7
U
T0??@`
>Mantissa 2
T??0
N Exponent&
2 H
0h ? [RIȺ*=zdj=
}(
~
s*
U
~
s*
@pP
9
0j @,$D0
Step 4: Convert binary number to the FP equivalent (i.e. Add all column values with 1s in them)
0.01012 =  ( 0.25 + 0.0625)
= 0.312510a0Z3 <e[egg o g g$o$g$H
0h ? [RIȺ*=zdj
<(
~
s*Mantissa 2
(
T쟋??
N Exponent&
2 H
(0h ? [RIȺ*=zdj`
,(
,~
, s*ܢ
U
j
, s*<
p<$0j
&x h_7
,
0ԭ @0 ,$D0
0Step 3: Denormalize the binary number from step 2 (i.e. move the decimal and get rid of (x 2n) part:
11001.12 (positive exponent move right)
0ZeXemegg o !eegg$ h_7H
,0h ? [RIȺ*=zdjrl`b4i11ac!#%(@,D.\168:t>CEGIKOSUW[
a)(՜.+,0
4Onscreen ShowRegis University e)V
]Times New RomanTahoma
Wingdings
Arial NarrowArialCourier NewBlendsSigned NumbersSigned NumbersSign/Magnitude RepresentationSign/Magnitude RepresentationSign/Magnitude RepresentationSign/Magnitude RepresentationSign/Magnitude RepresentationSign/Magnitude RepresentationProblems with Sign/Magnitude Twos Complement Representation Twos Complement Representation Twos Complement Representation Twos Complement Representation Twos Complement Representation Twos Complement Representation Twos Complement Representation Twos Complement Representation Twos Complement Representation Twos Complement Representation Twos Complement Representation Twos Complement Representation Twos Complement Representation Twos Complement Representation Twos Complement Representation Twos Complement RepresentationTwos Complement to DecimalTwos Complement to DecimalTwos Complement to DecimalTwos Complement to DecimalTwos Complement to DecimalTwos Complement to DecimalTwos Complement to DecimalTwos Complement to Decimal'S/M problems solved with 2s complement Twos Complement Representation Twos Complement RepresentationTwos Complement Representation Twos Complement Representation
Valid RangesUnsigned Integer RangesUnsigned Integer RangesSigned S/M Integer RangesS/M Integer RangesTwos Complement RangesTwos Complement Ranges#Using Ranges for Validity Checking#Using Ranges for Validity Checking#Using Ranges for Validity CheckingFloating Point NumbersFloating Point NumbersFloating Point NumbersFloating Point Numbers Binary Equivalence (Fractional Part Multiplication Method(Fractional Part Multiplication Method(Fractional Part Multiplication Method%Fractional Part Subtraction Method%Fractional Part Subtraction MethodBinary Equivalent of FP numberBinary Equivalent of FP numberProblem storing binary form#IEEE Floating Point Representation#IEEE Floating Point RepresentationStoring the Binary FormSolution is Normalization#IEEE Floating Point RepresentationTry It YourselfAnswers#IEEE Floating Point Representation3Decimal Floating Point to IEEE standard Conversion3Decimal Floating Point to IEEE standard Conversion3Decimal Floating Point to IEEE standard Conversion3Decimal Floating Point to IEEE standard Conversion3Decimal Floating Point to IEEE standard Conversion3Decimal Floating Point to IEEE standard Conversion3Decimal Floating Point to IEEE standard Conversion4Decimal Floating Point to IEEE standard Conversion.5IEEE standard to Decimal Floating Point Conversion.5IEEE standard to Decimal Floating Point Conversion.6IEEE standard to Decimal Floating Point Conversion..6IEEE standard to Decimal Floating Point Conversion..5IEEE standard to Decimal Floating Point Conversion.5IEEE standard to Decimal Floating Point Conversion.6IEEE standard to Decimal Floating Point Conversion..6IEEE standa<
jSigned NumbersrUntil now we've been concentrating on unsigned numbers. In real life we also need to be able represent signed numbers ( like: 12, 45, +78).
A signed number MUST have a sign (+/). A method is needed to represent the sign as part of the binary representation.
Two signed number representation methods are:
Sign/magnitude representation
Twoscomplement representation6 2= 2&9Sign/Magnitude Representation
In sign/magnitude (S/M) representation, the leftmost bit of a binary code represents the sign of the value:
0 for positive,
1 for negative;
The remaining bits represent the numeric value. o
"
3
',GG;GGGGG2Gg,oDSign/Magnitude RepresentationTo compute negative values using Sign/Magnitude (S/M) representation:
Begin with the binary representation of the positive value
Then flip the leftmost zero bit.
J;
" " #
" " IG,GGG#GgSign/Magnitude Representation5Ex 1. Find the S/M representation of 610
/8Z2pZF%Sign/Magnitude Representation1 Ex 2. Find the S/M representation of 7010
pZ2
p}2
G#GOGGMSign/Magnitude Representation2 Ex 3. Find the S/M representation of 3610
.pZ2
p}2
G$GOGGSign/Magnitude Representation
Problems with Sign/Magnitude
>Two s Complement Representation (Another method used to represent negative numbers (used by most modern computers) is two s complement.
The leftmost bit STILL serves as a sign bit:
0 for positive numbers,
1 for negative numbers.
4hGG/G4Gg,>Two s Complement Representation (To compute negative values using Two s Complement representation:
Begin with the binary representation of the positive value
Complement (flip each bit  if it is 0 make it 1 and visa versa) the entire positive number
Then add one.CZ
" ZGG0GGg>Two s Complement Representation (2Ex 1. Find the 8bit two s complement representation of 610
Step 1: Find binary representation of the positive value in 8 bits
610 = 0000011027!
!!C
!
!$! >Two s Complement Representation (z Ex 1 continued Step 2: Complement the entire positive value
Positive Value: 00000110
Complemented: 11111001r{( !a>Two s Complement Representation (7So: 610 = 111110102
(in 8bit 2's complement form)8EG$O$G$O$G$EEGgE>Two s Complement Representation (Ex 2. Find the 8bit two s complement representation of 2010
Step 1: Find binary representation of the positive value in 8 bits
2010 = 000101002
20 is positive, so STOP after step 1!0U
G8GOGGCGOGG!O!G!'G;>Two s Complement Representation (vEx 3. Find the 8bit two s complement representation of 8010
Step 1: Find binary representation of the positive value in 8 bits
8010 = 010100002
80 is negative, so continue& 9E!!<>Two s Complement Representation (v Ex 3 Step 2: Complement the entire positive value
Positive Value: 01010000
Complemented: 10101111w< !=>Two s Complement Representation (8So: 8010 = 101100002
(in 8bit 2's complement form)9GGOGOGGg
>Two s Complement Representation (2 Alternate method  replaces previous steps 23
F3ZG1GG>Two s Complement Representation (`Ex 1: Find the Two s Complement of 7610
n1ZG$GOGG>Two s Complement Representation (Step 2: Find first one bit, from loworder (right) end, and complement the pattern to the left.
01001100
(left complemented) > 10110100
Z G WGgG G G G G g Gg>>Two s Complement Representation (Ex 2: Find the Two s Complement of 7210
Step 1: Find the 8 bit binary representation of the positive value.
7210 = 010010002 <G GOGG<GgGOGOg?>Two s Complement Representation (`Ex 3: Find the Two s Complement of 2610
1ZG!GG O GG@>Two s Complement Representation (Ex 3, Step 2: Find first one bit, from loworder (right) end, and complement the pattern to the left.
00011010
(left complemented) > 11100110
ZG
EWEe)EEEeG>Two s Complement Representation (
76Two s Complement to Decimal(Ex 1: Find the decimal equivalent of the
8bit 2 s complement value 111011002
dRZH86Two s Complement to Decimal(~Ex 1, Step 2: Find first one bit, from loworder (right) end, and complement the pattern to the left.
11101100G
G$WEeG$G(G$:6Two s Complement to Decimal(Ex 1, Step 3: Determine the numeric value:
000101002 = 16 + 4 = 2010
So: 111011002 = 2010 (8bit 2's complement form)^((($$$$$$(($$$$A6Two s Complement to Decimal(Ex 2: Find the decimal equivalent of the
8bit 2 s complement value 010010002
dRZHF6Two s Complement to Decimal(~Ex2, Step 3: Determine the numeric value:
010010002 = 64 + 8 = 7210
So: 010010002 = 7210 (8bit 2's complement form)* ($$$$$$($$$$$D6Two s Complement to Decimal(Ex 3: Find the decimal equivalent of the
8bit 2 s complement value 110010002
RZ?B6Two s Complement to Decimal(~Ex 3, Step 2: Find first one bit, from loworder (right) end, and complement the pattern to the left.
11001000~GWGgG$G((C6Two s Complement to Decimal(Ex 3, Step 3: Determine the numeric value:
001110002 = 32 + 16 + 8 = 5610
So: 110010002 = 5610 (8bit 2's complement form) ($$$$$$$$$$$&S/M problems solved with 2s complement''(
>Two s Complement Representation (Biggest reason two s complement used in most systems today?
The binary codes can be added and subtracted as if they were unsigned binary numbers, without regard to the signs of the numbers they actually represent.
*>Two s Complement Representation (]For example, to add +4 and 3, we simply add the corresponding binary codes, 0100 and 1101:
F^Z[GgGTwos Complement Representation(DLikewise, to subtract +7 from +3:
0011 (+3)
 0111 (+7)
1100 (4)
NOTE: A phantom 1 was borrowed from beyond the leftmost position.Z"GgGgGGGGgGgE>Two s Complement Representation ( Summary  Benefits of Twos Complements:
Addition and subtraction are simplified in the two scomplement system,
0 has been eliminated, replaced by one extra negative value, for which there is no corresponding positive number. F) P P()Valid RangesFor any integer data representation, there is a LIMIT to the size of number that can be stored.
The limit depends upon number of bits available for data storage.J=7*Unsigned Integer RangesRange = 0 to (2n 1)
where n is the number of bits used to store the unsigned integer.
Numbers with values GREATER than (2n 1) would require more bits. If you try to store too large a value without using more bits, OVERFLOW will occur.ckcccc:cc!cckcmcC(Unsigned Integer RangeszExample: On a system that stores unsigned integers in 16bit words:
Range = 0 to (216 1)
= 0 to 65535
Therefore, you cannot store numbers larger than 65535 in 16 bits.Ey!FaaiaaaaCaADy+Signed S/M Integer RangesRange = (2(n1) 1) to +(2(n1) 1)
where n is the number of bits used to store the sign/magnitude integer.
Numbers with values GREATER than +(2(n1) 1) and values LESS than (2(n1) 1) would require more bits. If you try to store too large/too small a value without using more bits, OVERFLOW will occur.w
aiaiaaacc@ccc$c$"cckccckcvcb@,S/M Integer RangesExample: On a system that stores unsigned integers in 16bit words:
Range = (215 1) to +(215 1)
= 32767 to +32767
Therefore, you cannot store numbers larger than 32767 or smaller than 32767 in 16 bits.F%Ecc c k c k c c c c c Yc,D.Two s Complement RangesRange = 2(n1) to +(2(n1) 1)
where n is the number of bits used to store the twos complement signed integer.
Numbers with values GREATER than +(2(n1) 1) and values LESS than 2(n1) would require more bits. If you try to store too large/too small a value without using more bits, OVERFLOW will occur.{c k
c k c c c ccIccc$c$"cckccckcwcC ..Two s Complement RangesExample: On a system that stores unsigned integers in 16bit words:
Range = 215 to +(215 1)
= 32768 to +32767
Therefore, you cannot store numbers larger than 32767 or smaller than 32768 in 16 bits.F%Fcc
c k c k c c c c c YcD1"Using Ranges for Validity CheckingOnce you know how small/large a value can be stored in n bits, you can use this knowledge to check whether you answers are valid, or cause overflow.
Overflow can only occur if you are adding two positive numbers or two negative numbers
@
2"Using Ranges for Validity Checking6Ex 1:
Given the following 2 s complement equations in 5 bits, is the answer valid?
11111 (1) Range =
+11101 (3) 16 to +15
11100 (4) VALID
T
J"Using Ranges for Validity Checking>Ex 2:
Given the following 2 s complement equations in 5 bits, is the answer valid?
10111 (9) Range =
+10101 (11) 16 to +15
01100 (20) INVALID
T
!!!NFloating Point Numbers<
OFloating Point NumbersNow you've seen unsigned and signed integers. In real life we also need to be able represent numbers with fractional parts (like: 12.5 & 45.39). ` KpPFloating Point NumbersIn the decimal system, a decimal point (radix point) separates the whole numbers from the fractional part
Examples:
37.25 ( whole = 37, fraction = 25/100)
123.567
10.12345678
`uB)QFloating Point Numbers For example, 37.25 can be analyzed as:
101 100 101 102
Tens Units Tenths Hundredths
3 7 2 5
37.25 = (3 x 10) + (7 x 1) + (2 x 1/10) + (5 x 1/100)
l&GgGOGOGOGOo"GgGG6GgGRBinary Equivalence The binary equivalent of a floating point number can be determined by computing the binary representation for each part separately.
: 2(2SNFractional Part Multiplication Method(( 4 In the binary representation of a floating point number the column values will be as follows:
& 25 24 23 22 21 20 . 21 22 23 24 &
& 32 16 8 4 2 1 . 1/2 1/4 1/8 1/16&
& 32 16 8 4 2 1 . .5 .25 .125 .0625&
^33339<, TNFractional Part Multiplication Method(( Ex 1. Find the binary equivalent of 0.25
Step 1: Multiply the fraction by 2 until the fractional part becomes 0 .25
x 2
0.5
x 2
1.0
ZZG!G
GGG)GCGgGGgGGGGGgCGGCG(UNFractional Part Multiplication Method(( Ex 2. Find the binary equivalent of 0.625
Step 1: Multiply the fraction by 2 until the fractional part becomes 0 .625
x 2
1.25
x 2
0.50
x 2
1.0
PZZG!GGGG)GCG gGGg
GGGGGg
CGGGGGGGGCG5VHFractional Part Subtraction Method%% Start with the column values again, as follows:
& 20 . 21 22 23 24 25 26&
& 1 . 1/2 1/4 1/8 1/16 1/32 1/64&
& 1 . .5 .25 .125 .0625 .03125 .015625&
"3333
25WWHFractional Part Subtraction Method%% Starting with 0.5, subtract the column values from left to right. Insert a 0 in the column if the value cannot be subtracted or 1 if it can be. Continue until the fraction becomes .0
Ex 1.
.25 .5 .25 .125 .0625
 .25 .0 1
.0
Z@ZGG33GGG
GGgG33XBinary Equivalent of FP numberEx 2. Convert 37.25, using subtraction method.
64 32 16 8 4 2 1 . .5 .25 .125 .0625
26 25 24 23 22 21 20 . 21 22 23 24
0G*GgC G33G!G33O33G33O33G33O33G33O33G33O33G33O33G33O33G33G!G33O33G33O33G33O33G33O33 CGWYYBinary Equivalent of FP numberPEx 3. Convert 18.625, using subtraction method.
64 32 16 8 4 2 1 . .5 .25 .125 .0625
26 25 24 23 22 21 20 . 21 22 23 24
1 0 0 1 0 1 0 1
18 .625
 16  .5
2 .125
 2  .125
0 01ZxZ0ZxZG,GgC G33G!G33O33G33O33G33O33G33O33G33O33G33O33G33O33G33G!G33O33G33O33G33O33G33O33/GG'
'X\Problem storing binary formWe have no way to store the radix point!
Standards committee came up with a way to store floating point numbers (that have a decimal point) P]"IEEE Floating Point Representation##$Floating point numbers can be stored into 32bits, by dividing the bits into three parts:
the sign, the exponent, and the mantissa.
Z 2.(2`
%^"IEEE Floating Point Representation##$The first (leftmost) field of our floating point representation will STILL be the sign bit:
0 for a positive number,
1 for a negative number.
]3[EGG2G$g$g$6\_Storing the Binary FormHow do we store a radix point?
 All we have are zeros and ones&
Make sure that the radix point is ALWAYS in the same position within the number.
Use the IEEE 32bit standard
the leftmost digit must be a 1
BT!`Solution is Normalization% Every binary number, except the one corresponding to the number zero, can be normalized by choosing the exponent so that the radix point falls to the right of the leftmost 1 bit.
37.2510 = 100101.012 = 1.0010101 x 25
7.62510 = 111.1012 = 1.11101 x 22
0.312510 = 0.01012 = 1.01 x 22z&Z/94
!a"IEEE Floating Point Representation##$
The second field of the floating point number will be the exponent.
The exponent is stored as an unsigned 8bit number, RELATIVE to a bias of 127.
Exponent 5 is stored as (127 + 5) or 132
132 = 10000100
Exponent 5 is stored as (127 + (5)) or 122
122 = 01111010 )  :F
)! !bTry It YourselfkHow would the following exponents be stored (8bits, 127biased):
210
28
(Answers on next slide)
B% ) % BaaiaieaAcAnswers 210
exponent 10 8bit
bias +127 value
117 01110101
28
exponent 8 8bit
bias +127 value
135 10000111 !)!%!!!%
!%!)!%!!!%
!%d"IEEE Floating Point Representation##$The mantissa is the set of 0 s and 1 s to the left of the radix point of the normalized (when the digit to the left of the radix point is 1) binary number.
Ex: 1.00101 X 23
(The mantissa is 00101)
GGAG
GFGG"G"!G"O"O"EG$e2Decimal Floating Point toIEEE standard Conversion"32 " Ex 1: Find the IEEE FP representation of 40.15625
Step 1.
Compute the binary equivalent of the whole part and the fractional part. (i.e. convert 40 and .15625 to their binary equivalents) G3GgG\GGGGGG Cf2Decimal Floating Point toIEEE standard Conversion33 40 .15625
 32 Result: .12500 Result:
8 101000 .03125 .00101
 8 .03125
0 .0
So: 40.1562510 = 101000.001012
ZGgGGFFGGGF GG
GGGGGg
GgGgFF N F F N Ff'g2Decimal Floating Point toIEEE standard Conversion33 Step 2. Normalize the number by moving the decimal point to the right of the leftmost one.
101000.00101 = 1.0100000101 x 25
]'GVGgG
G G G O o G g h2Decimal Floating Point toIEEE standard Conversion33 Step 3. Convert the exponent to a biased exponent
127 + 5 = 132
And convert biased exponent to 8bit unsigned binary:
13210 = 100001002
ZG,Gg GGJGOGGOgGgi2Decimal Floating Point toIEEE standard Conversion33 Step 4. Store the results from steps 13:
Sign Exponent Mantissa
(from step 3) (from step 2)
0 10000100 01000001010000000000000
~G&G9G0Gg j2Decimal Floating Point toIEEE standard Conversion33 Ex 2: Find the IEEE FP representation of 24.75
Step 1. Compute the binary equivalent of the whole part and the fractional part.
24 .75
 16 Result:  .50 Result:
8 11000 .25 .11
 8  .25
0 .0
So: 24.7510 = 11000.112
ZfZ 8Z2ZG'GGGgGMGgGgGGG GgGG
GGgGGGgGg '', k2Decimal Floating Point toIEEE standard Conversion33 Step 2.
Normalize the number by moving the decimal point to the right of the leftmost one.
11000.11 = 1.100011 x 24
GXGgEMeEel3Decimal Floating Point toIEEE standard Conversion. 42 Step 3. Convert the exponent to a biased exponent
127 + 4 = 131
==> 13110 = 100000112
Step 4. Store the results from steps 13
Sign Exponent mantissa
1 10000011 1000110..0
@2ZZZG+Gg!GOGOgGG?GGgGo4IEEE standard to Decimal Floating Point Conversion. 53 Do the steps in reverse order
In reversing the normalization step move the radix point the number of digits equal to the exponent:
If exponent is positive, move to the right
If exponent is negative, move to the leftfUGgfGGGGGG GGGGp4IEEE standard to Decimal Floating Point Conversion. 53 Ex 1: Convert the following 32bit binary number to its decimal floating point equivalent:
Sign Exponent Mantissa
1 01111101 010..0
6]ZBZGXGgGgGgGGgGgGgq5IEEE standard to Decimal Floating Point Conversion.. 63 Step 1: Extract the biased exponent and unbias it
Biased exponent = 011111012 = 12510
Unbiased Exponent: 125 127 = 2
G+GgGEMEEME&EE$'Vr5IEEE standard to Decimal Floating Point Conversion.. 63 Step 2: Write Normalized number in the form:
1 . ____________ x 2 
For our number:
1. 01 x 2 2
wZG(GGGOGGGGOggGgks4IEEE standard to Decimal Floating Point Conversion. 53 *Step 3: Denormalize the binary number from step 2 (i.e. move the decimal and get rid of (x 2n) part):
0.01012 (negative exponent move left)
GWGOGgGG O G GGG$ t4IEEE standard to Decimal Floating Point Conversion. 53 Ex 2: Convert the following 32 bit binary number to its decimal floating point equivalent:
Sign Exponent Mantissa
0 10000011 10011000..0
[7GZGGGGGGgGGgEeu5IEEE standard to Decimal Floating Point Conversion.. 63 Step 1: Extract the biased exponent and unbias it
Biased exponent = 10000112 = 13110
Unbiased Exponent: 131 127 = 4
G+GgGEMEEME&EEE'Vv5IEEE standard to Decimal Floating Point Conversion.. 63 tStep 2: Write Normalized number in the form:
1 . ____________ x 2 
For our number:
1.10011 x 2 4
uG'GEEEMEEEG$
G$O$o$w4IEEE standard to Decimal Floating Point Conversion. 53 Step 4: Convert binary number to the FP equivalent (i.e. Add all column values with 1s in them)
11001.1 = 16 + 8 + 1 +.5
= 25.510a/(G[GG"G G$O$G$/pPra
aM)(
Root EntrydO)tOW@Current User<;SummaryInformation("PowerPoint Document(e)
!"#$%&'()*+,./0123456789:;<=>?@ABCDEFGHPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{}~
NO
} !"#$%&'()*+,./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{~
!"#$%&'()*+,./0123456789:;rd to Decimal Floating Point Conversion..5IEEE standard to Decimal Floating Point Conversion.Fonts UsedDesign Template
Slide TitlesV!_A) SmallwoodSmallwoodllwood
nn
CG
CGCG&'?@ VXCG+/
CGVX&'?@
! 9AktVXCGCGCGon
& !(Y
Z
3$00 %& *)2"#.
#3456789:;<=>?@
ABCDEFGHIJKLMNOPQRSTUVWX0e0eA@A5%8c8c
?1d0u0@Ty2 NP'p<'p@A)BCDE? @!ff+h@8uʚ;mNʚ;g4CdCdv0pppp@<4!d!d`
0,5<4dddd`
0,5g4:d:dv0pp]pp<4BdBd`
0,5N___PPT94 ?%O=KSigned Numbers<
jSigned NumbersrUntil now we've been concentrating on unsigned numbers. In real life we also need to be able represent signed numbers ( like: 12, 45, +78).
A signed number MUST have a sign (+/). A method is needed to represent the sign as part of the binary representation.
Two signed number representation methods are:
Sign/magnitude representation
Twoscomplement representation6 2= 2&9Sign/Magnitude Representation
In sign/magnitude (S/M) representation, the leftmost bit of a binary code represents the sign of the value:
0 for positive,
1 for negative;
The remaining bits represent the numeric value. o
"
3
',GG;GGGGG2Gg,oDSign/Magnitude RepresentationTo compute negative values using Sign/Magnitude (S/M) representation:
Begin with the binary representation of the positive value
Then flip the leftmost zero bit.
J;
" " #
" " IG,GGG#GgSign/Magnitude Representation5Ex 1. Find the S/M representation of 610
/8Z2pZF%Sign/Magnitude Representation1 Ex 2. Find the S/M representation of 7010
pZ2
p}2
G#GOGGMSign/Magnitude Representation2 Ex 3. Find the S/M representation of 3610
.pZ2
p}2
G$GOGGSign/Magnitude Representation
Problems with Sign/Magnitude
>Two s Complement Representation (Another method used to represent negative numbers (used by most modern computers) is two s complement.
The leftmost bit STILL serves as a sign bit:
0 for positive numbers,
1 for negative numbers.
4hGG/G4Gg,>Two s Complement Representation (To compute negative values using Two s Complement representation:
Begin with the binary representation of the positive value
Complement (flip each bit  if it is 0 make it 1 and visa versa) the entire positive number
Then add one.CZ
" ZGG0GGg>Two s Complement Representation (2Ex 1. Find the 8bit two s complement representation of 610
Step 1: Find binary representation of the positive value in 8 bits
610 = 0000011027!
!!C
!
!$! >Two s Complement Representation (z Ex 1 continued Step 2: Complement the entire positive value
Positive Value: 00000110
Complemented: 11111001r{( !a>Two s Complement Representation (7So: 610 = 111110102
(in 8bit 2's complement form)8EG$O$G$O$G$EEGgE>Two s Complement Representation (Ex 2. Find the 8bit two s complement representation of 2010
Step 1: Find binary representation of the positive value in 8 bits
2010 = 000101002
20 is positive, so STOP after step 1!0U
G8GOGGCGOGG!O!G!'G;>Two s Complement Representation (vEx 3. Find the 8bit two s complement representation of 8010
Step 1: Find binary representation of the positive value in 8 bits
8010 = 010100002
80 is negative, so continue& 9E!!<>Two s Complement Representation (v Ex 3 Step 2: Complement the entire positive value
Positive Value: 01010000
Complemented: 10101111w< !=>Two s Complement Representation (8So: 8010 = 101100002
(in 8bit 2's complement form)9GGOGOGGg
>Two s Complement Representation (2 Alternate method  replaces previous steps 23
F3ZG1GG>Two s Complement Representation (`Ex 1: Find the Two s Complement of 7610
n1ZG$GOGG>Two s Complement Representation (Step 2: Find first one bit, from loworder (right) end, and complement the pattern to the left.
01001100
(left complemented) > 10110100
Z G WGgG G G G G g Gg>>Two s Complement Representation (Ex 2: Find the Two s Complement of 7210
Step 1: Find the 8 bit binary representation of the positive value.
7210 = 010010002 <G GOGG<GgGOGOg?>Two s Complement Representation (`Ex 3: Find the Two s Complement of 2610
1ZG!GG O GG@>Two s Complement Representation (Ex 3, Step 2: Find first one bit, from loworder (right) end, and complement the pattern to the left.
00011010
(left complemented) > 11100110
ZG
EWEe)EEEeG>Two s Complement Representation (
76Two s Complement to Decimal(Ex 1: Find the decimal equivalent of the
8bit 2 s complement value 111011002
dRZH86Two s Complement to Decimal(~Ex 1, Step 2: Find first one bit, from loworder (right) end, and complement the pattern to the left.
11101100G
G$WEeG$G(G$:6Two s Complement to Decimal(Ex 1, Step 3: Determine the numeric value:
000101002 = 16 + 4 = 2010
So: 111011002 = 2010 (8bit 2's complement form)^((($$$$$$(($$$$A6Two s Complement to Decimal(Ex 2: Find the decimal equivalent of the
8bit 2 s complement value 010010002
dRZHF6Two s Complement to Decimal(~Ex2, Step 3: Determine the numeric value:
010010002 = 64 + 8 = 7210
So: 010010002 = 7210 (8bit 2's complement form)* ($$$$$$($$$$$D6Two s Complement to Decimal(Ex 3: Find the decimal equivalent of the
8bit 2 s complement value 110010002
RZ?B6Two s Complement to Decimal(~Ex 3, Step 2: Find first one bit, from loworder (right) end, and complement the pattern to the left.
11001000~GWGgG$G((C6Two s Complement to Decimal(Ex 3, Step 3: Determine the numeric value:
001110002 = 32 + 16 + 8 = 5610
So: 110010002 = 5610 (8bit 2's complement form) ($$$$$$$$$$$&S/M problems solved with 2s complement''(
>Two s Complement Representation (Biggest reason two s complement used in most systems today?
The binary codes can be added and subtracted as if they were unsigned binary numbers, without regard to the signs of the numbers they actually represent.
*>Two s Complement Representation (]For example, to add +4 and 3, we simply add the corresponding binary codes, 0100 and 1101:
F^Z[GgGTwos Complement Representation(DLikewise, to subtract +7 from +3:
0011 (+3)
 0111 (+7)
1100 (4)
NOTE: A phantom 1 was borrowed from beyond the leftmost position.Z"GgGgGGGGgGgE>Two s Complement Representation ( Summary  Benefits of Twos Complements:
Addition and subtraction are simplified in the two scomplement system,
0 has been eliminated, replaced by one extra negative value, for which there is no corresponding positive number. F) P P()Valid RangesFor any integer data representation, there is a LIMIT to the size of number that can be stored.
The limit depends upon number of bits available for data storage.J=7*Unsigned Integer RangesRange = 0 to (2n 1)
where n is the number of bits used to store the unsigned integer.
Numbers with values GREATER than (2n 1) would require more bits. If you try to store too large a value without using more bits, OVERFLOW will occur.ckcccc:cc!cckcmcC(Unsigned Integer RangeszExample: On a system that stores unsigned integers in 16bit words:
Range = 0 to (216 1)
= 0 to 65535
Therefore, you cannot store numbers larger than 65535 in 16 bits.Ey!FaaiaaaaCaADy+Signed S/M Integer RangesRange = (2(n1) 1) to +(2(n1) 1)
where n is the number of bits used to store the sign/magnitude integer.
Numbers with values GREATER than +(2(n1) 1) and values LESS than (2(n1) 1) would require more bits. If you try to store too large/too small a value without using more bits, OVERFLOW will occur.w
aiaiaaacc@ccc$c$"cckccckcvcb@,S/M Integer RangesExample: On a system that stores unsigned integers in 16bit words:
Range = (215 1) to +(215 1)
= 32767 to +32767
Therefore, you cannot store numbers larger than 32767 or smaller than 32767 in 16 bits.F%Ecc c k c k c c c c c Yc,D.Two s Complement RangesRange = 2(n1) to +(2(n1) 1)
where n is the number of bits used to store the twos complement signed integer.
Numbers with values GREATER than +(2(n1) 1) and values LESS than 2(n1) would require more bits. If you try to store too large/too small a value without using more bits, OVERFLOW will occur.{c k
c k c c c ccIccc$c$"cckccckcwcC ..Two s Complement RangesExample: On a system that stores unsigned integers in 16bit words:
Range = 215 to +(215 1)
= 32768 to +32767
Therefore, you cannot store numbers larger than 32767 or smaller than 32768 in 16 bits.F%Fcc
c k c k c c c c c YcD1"Using Ranges for Validity CheckingOnce you know how small/large a value can be stored in n bits, you can use this knowledge to check whether you answers are valid, or cause overflow.
Overflow can only occur if you are adding two positive numbers or two negative numbers
@
2"Using Ranges for Validity Checking6Ex 1:
Given the following 2 s complement equations in 5 bits, is the answer valid?
11111 (1) Range =
+11101 (3) 16 to +15
11100 (4) VALID
T
J"Using Ranges for Validity Checking>Ex 2:
Given the following 2 s complement equations in 5 bits, is the answer valid?
10111 (9) Range =
+10101 (11) 16 to +15
01100 (20) INVALID
T
!!!NFloating Point Numbers<
OFloating Point NumbersNow you've seen unsigned and signed integers. In real life we also need to be able represent numbers with fractional parts (like: 12.5 & 45.39). ` KpPFloating Point NumbersIn the decimal system, a decimal point (radix point) separates the whole numbers from the fractional part
Examples:
37.25 ( whole = 37, fraction = 25/100)
123.567
10.12345678
`uB)QFloating Point Numbers For example, 37.25 can be analyzed as:
101 100 101 102
Tens Units Tenths Hundredths
3 7 2 5
37.25 = (3 x 10) + (7 x 1) + (2 x 1/10) + (5 x 1/100)
l&GgGOGOGOGOo"GgGG6GgGRBinary Equivalence The binary equivalent of a floating point number can be determined by computing the binary representation for each part separately.
: 2(2SNFractional Part Multiplication Method(( 4 In the binary representation of a floating point number the column values will be as follows:
& 25 24 23 22 21 20 . 21 22 23 24 &
& 32 16 8 4 2 1 . 1/2 1/4 1/8 1/16&
& 32 16 8 4 2 1 . .5 .25 .125 .0625&
^33339<, TNFractional Part Multiplication Method(( Ex 1. Find the binary equivalent of 0.25
Step 1: Multiply the fraction by 2 until the fractional part becomes 0 .25
x 2
0.5
x 2
1.0
ZZG!G
GGG)GCGgGGgGGGGGgCGGCG(UNFractional Part Multiplication Method(( Ex 2. Find the binary equivalent of 0.625
Step 1: Multiply the fraction by 2 until the fractional part becomes 0 .625
x 2
1.25
x 2
0.50
x 2
1.0
PZZG!GGGG)GCG gGGg
GGGGGg
CGGGGGGGGCG5VHFractional Part Subtraction Method%% Start with the column values again, as follows:
& 20 . 21 22 23 24 25 26&
& 1 . 1/2 1/4 1/8 1/16 1/32 1/64&
& 1 . .5 .25 .125 .0625 .03125 .015625&
"3333
25WWHFractional Part Subtraction Method%% Starting with 0.5, subtract the column values from left to right. Insert a 0 in the column if the value cannot be subtracted or 1 if it can be. Continue until the fraction becomes .0
Ex 1.
.25 .5 .25 .125 .0625
 .25 .0 1
.0
Z@ZGG33GGG
GGgG33XBinary Equivalent of FP numberEx 2. Convert 37.25, using subtraction method.
64 32 16 8 4 2 1 . .5 .25 .125 .0625
26 25 24 23 22 21 20 . 21 22 23 24
0G*GgC G33G!G33O33G33O33G33O33G33O33G33O33G33O33G33O33G33G!G33O33G33O33G33O33G33O33 CGWYYBinary Equivalent of FP numberPEx 3. Convert 18.625, using subtraction method.
64 32 16 8 4 2 1 . .5 .25 .125 .0625
26 25 24 23 22 21 20 . 21 22 23 24
1 0 0 1 0 1 0 1
18 .625
 16  .5
2 .125
 2  .125
0 01ZxZ0ZxZG,GgC G33G!G33O33G33O33G33O33G33O33G33O33G33O33G33O33G33G!G33O33G33O33G33O33G33O33/GG'
'X\Problem storing binary formWe have no way to store the radix point!
Standards committee came up with a way to store floating point numbers (that have a decimal point) P]"IEEE Floating Point Representation##$Floating point numbers can be stored into 32bits, by dividing the bits into three parts:
the sign, the exponent, and the mantissa.
Z 2.(2`
%^"IEEE Floating Point Representation##$The first (leftmost) field of our floating point representation will STILL be the sign bit:
0 for a positive number,
1 for a negative number.
]3[EGG2G$g$g$6\_Storing the Binary FormHow do we store a radix point?
 All we have are zeros and ones&
Make sure that the radix point is ALWAYS in the same position within the number.
Use the IEEE 32bit standard
the leftmost digit must be a 1
BT!`Solution is Normalization% Every binary number, except the one corresponding to the number zero, can be normalized by choosing the exponent so that the radix point falls to the right of the leftmost 1 bit.
37.2510 = 100101.012 = 1.0010101 x 25
7.62510 = 111.1012 = 1.11101 x 22
0.312510 = 0.01012 = 1.01 x 22z&Z/94
!a"IEEE Floating Point Representation##$
The second field of the floating point number will be the exponent.
The exponent is stored as an unsigned 8bit number, RELATIVE to a bias of 127.
Exponent 5 is stored as (127 + 5) or 132
132 = 10000100
Exponent 5 is stored as (127 + (5)) or 122
122 = 01111010 )  :F
)! !bTry It YourselfkHow would the following exponents be stored (8bits, 127biased):
210
28
(Answers on next slide)
B! ) ! BaaiaieaAcAnswers 210
exponent 10 8bit
bias +127 value
117 01110101
28
exponent 8 8bit
bias +127 value
135 10000111 !)!%!!!%
!%!)!%!!!%
!%d"IEEE Floating Point Representation##$The mantissa is the set of 0 s and 1 s to the right of the radix point of the normalized (when the digit to the left of the radix point is 1) binary number.
Ex: 1.00101 X 23
(The mantissa is 00101)
GGBG
GFGG"G"!G"O"O"EG$e2Decimal Floating Point toIEEE standard Conversion"32 " Ex 1: Find the IEEE FP representation of 40.15625
Step 1.
Compute the binary equivalent of the whole part and the fractional part. (i.e. convert 40 and .15625 to their binary equivalents) G3GgG\GGGGGG Cf2Decimal Floating Point toIEEE standard Conversion33 40 .15625
 32 Result: .12500 Result:
8 101000 .03125 .00101
 8 .03125
0 .0
So: 40.1562510 = 101000.001012
ZGgGGFFGGGF GG
GGGGGg
GgGgFF N F F N Ff'g2Decimal Floating Point toIEEE standard Conversion33 Step 2. Normalize the number by moving the decimal point to the right of the leftmost one.
101000.00101 = 1.0100000101 x 25
]'GVGgG
G G G O o G g h2Decimal Floating Point toIEEE standard Conversion33 Step 3. Convert the exponent to a biased exponent
127 + 5 = 132
And convert biased exponent to 8bit unsigned binary:
13210 = 100001002
ZG,Gg GGJGOGGOgGgi2Decimal Floating Point toIEEE standard Conversion33 Step 4. Store the results from steps 13:
Sign Exponent Mantissa
(from step 3) (from step 2)
0 10000100 01000001010000000000000
~G&G9G0Gg j2Decimal Floating Point toIEEE standard Conversion33 Ex 2: Find the IEEE FP representation of 24.75
Step 1. Compute the binary equivalent of the whole part and the fractional part.
24 .75
 16 Result:  .50 Result:
8 11000 .25 .11
 8  .25
0 .0
So: 24.7510 = 11000.112
ZfZ 8Z2ZG'GGGgGMGgGgGGG GgGG
GGgGGGgGg '', k2Decimal Floating Point toIEEE standard Conversion33 Step 2.
Normalize the number by moving the decimal point to the right of the leftmost one.
11000.11 = 1.100011 x 24
GXGgEMeEel3Decimal Floating Point toIEEE standard Conversion. 42 Step 3. Convert the exponent to a biased exponent
127 + 4 = 131
==> 13110 = 100000112
Step 4. Store the results from steps 13
Sign Exponent mantissa
1 10000011 1000110..0
@2ZZZG+Gg!GOGOgGG?GGgGo4IEEE standard to Decimal Floating Point Conversion. 53 Do the steps in reverse order
In reversing the normalization step move the radix point the number of digits equal to the exponent:
If exponent is positive, move to the right
If exponent is negative, move to the leftfUGgfGGGGGG GGGGp4IEEE standard to Decimal Floating Point Conversion. 53 Ex 1: Convert the following 32bit binary number to its decimal floating point equivalent:
Sign Exponent Mantissa
1 01111101 010..0
6]ZBZGXGgGgGgGGgGgGgq5IEEE standard to Decimal Floating Point Conversion.. 63 Step 1: Extract the biased exponent and unbias it
Biased exponent = 011111012 = 12510
Unbiased Exponent: 125 127 = 2
G+GgGEMEEME&EE$'Vr5IEEE standard to Decimal Floating Point Conversion.. 63 Step 2: Write Normalized number in the form:
1 . ____________ x 2 
For our number:
1. 01 x 2 2
wZG(GGGOGGGGOggGgks4IEEE standard to Decimal Floating Point Conversion. 53 *Step 3: Denormalize the binary number from step 2 (i.e. move the decimal and get rid of (x 2n) part):
0.01012 (negative exponent move left)
GWGOGgGG O G GGG$ t4IEEE standard to Decimal Floating Point Conversion. 53 Ex 2: Convert the following 32 bit binary number to its decimal floating point equivalent:
Sign Exponent Mantissa
0 10000011 10011000..0
[7GZGGGGGGgGGgEeu5IEEE standard to Decimal Floating Point Conversion.. 63 Step 1: Extract the biased exponent and unbias it
Biased exponent = 10000112 = 13110
Unbiased Exponent: 131 127 = 4
G+GgGEMEEME&EEE'Vv5IEEE standard to Decimal Floating Point Conversion.. 63 tStep 2: Write Normalized number in the form:
1 . ____________ x 2 
For our number:
1.10011 x 2 4
uG'GEEEMEEEG$
G$O$o$w4IEEE standard to Decimal Floating Point Conversion. 53 Step 4: Convert binary number to the FP equivalent (i.e. Add all column values with 1s in them)
11001.1 = 16 + 8 + 1 +.5
= 25.510a/(G[GG"G G$O$G$/pP
iap
(
~
s*
U
~
s*
P{
0
PP,$D0
!qThe mantissa is stored in a 23 bit field, so we add zeros to the right side and store:
00101000000000000000000
~W0Z0ZWggg!gH
0h ? [RIȺ*=zdjrM9d
MB=C(
/0DTimes New Roman4dv0(
0DTahomaew Roman4dv0(
0T" DWingdingsRoman4dv0(
0T0DArial Narrowan4dv0(
0T"@DArialNarrowan4dv0(
0T"PDCourier Newan4dv0(
0T1a.
@n?" dd@ @@``x<^
nn
CG
CGCG&'?@ VXCG+/
CGVX&'?@
! 9AktVXCGCGCGon
& !(Y
Z[3\]0^ %& *)2"#.
#3456789:;<=>?@
ABCDEFGHIJKLMNOPQRSTUVWX0e0eA@A5%8c8c
?1d0u0@Ty2 NP'p<'p@A)BCDE? @!ff+h@8uʚ;mNʚ;g4CdCdv0pppp@<4!d!d`
0,5<4dddd`
0,5g4:d:dv0pp]pp<4BdBd`
0,5N___PPT94 ?%O=KSigned Numbers<
jSigned NumbersrUntil now we've been concentrating on unsigned numbers. In real life we also need to be able represent signed numbers ( like: 12, 45, +78).
A signed number MUST have a sign (+/). A method is needed to represent the sign as part of the binary representation.
Two signed number representation methods are:
Sign/magnitude representation
Twoscomplement representation6 2= 2&9Sign/Magnitude Representation
In sign/magnitude (S/M) representation, the leftmost bit of a binary code represents the sign of the value:
0 for positive,
1 for negative;
The remaining bits represent the numeric value. o
"
3
',GG;GGGGG2Gg,oDSign/Magnitude RepresentationTo compute negative values using Sign/Magnitude (S/M) representation:
Begin with the binary representation of the positive value
Then flip the leftmost zero bit.
J;
" " #
" " IG,GGG#GgSign/Magnitude Representation5Ex 1. Find the S/M representation of 610
/8Z2pZF%Sign/Magnitude Representation1 Ex 2. Find the S/M representation of 7010
pZ2
p}2
G#GOGGMSign/Magnitude Representation2 Ex 3. Find the S/M representation of 3610
.pZ2
p}2
G$GOGGSign/Magnitude Representation
Problems with Sign/Magnitude
>Two s Complement Representation (Another method used to represent negative numbers (used by most modern computers) is two s complement.
The leftmost bit STILL serves as a sign bit:
0 for positive numbers,
1 for negative numbers.
4hGG/G4Gg,>Two s Complement Representation (To compute negative values using Two s Complement representation:
Begin with the binary representation of the positive value
Complement (flip each bit  if it is 0 make it 1 and visa versa) the entire positive number
Then add one.CZ
" ZGG0GGg>Two s Complement Representation (2Ex 1. Find the 8bit two s complement representation of 610
Step 1: Find binary representation of the positive value in 8 bits
610 = 0000011027!
!!C
!
!$! >Two s Complement Representation (z Ex 1 continued Step 2: Complement the entire positive value
Positive Value: 00000110
Complemented: 11111001r{( !a>Two s Complement Representation (7So: 610 = 111110102
(in 8bit 2's complement form)8EG$O$G$O$G$EEGgE>Two s Complement Representation (Ex 2. Find the 8bit two s complement representation of 2010
Step 1: Find binary representation of the positive value in 8 bits
2010 = 000101002
20 is positive, so STOP after step 1!0U
G8GOGGCGOGG!O!G!'G;>Two s Complement Representation (vEx 3. Find the 8bit two s complement representation of 8010
Step 1: Find binary representation of the positive value in 8 bits
8010 = 010100002
80 is negative, so continue& 9E!!<>Two s Complement Representation (v Ex 3 Step 2: Complement the entire positive value
Positive Value: 01010000
Complemented: 10101111w< !=>Two s Complement Representation (8So: 8010 = 101100002
(in 8bit 2's complement form)9GGOGOGGg
>Two s Complement Representation (2 Alternate method  replaces previous steps 23
F3ZG1GG>Two s Complement Representation (`Ex 1: Find the Two s Complement of 7610
n1ZG$GOGG>Two s Complement Representation (Step 2: Find first one bit, from loworder (right) end, and complement the pattern to the left.
01001100
(left complemented) > 10110100
Z G WGgG G G G G g Gg>>Two s Complement Representation (Ex 2: Find the Two s Complement of 7210
Step 1: Find the 8 bit binary representation of the positive value.
7210 = 010010002 <G GOGG<GgGOGOg?>Two s Complement Representation (`Ex 3: Find the Two s Complement of 2610
1ZG!GG O GG@>Two s Complement Representation (Ex 3, Step 2: Find first one bit, from loworder (right) end, and complement the pattern to the left.
00011010
(left complemented) > 11100110
ZG
EWEe)EEEeG>Two s Complement Representation (
76Two s Complement to Decimal(Ex 1: Find the decimal equivalent of the
8bit 2 s complement value 111011002
dRZH86Two s Complement to Decimal(~Ex 1, Step 2: Find first one bit, from loworder (right) end, and complement the pattern to the left.
11101100G
G$WEeG$G(G$:6Two s Complement to Decimal(Ex 1, Step 3: Determine the numeric value:
000101002 = 16 + 4 = 2010
So: 111011002 = 2010 (8bit 2's complement form)^((($$$$$$(($$$$A6Two s Complement to Decimal(Ex 2: Find the decimal equivalent of the
8bit 2 s complement value 010010002
dRZHF6Two s Complement to Decimal(~Ex2, Step 3: Determine the numeric value:
010010002 = 64 + 8 = 7210
So: 010010002 = 7210 (8bit 2's complement form)* ($$$$$$($$$$$D6Two s Complement to Decimal(Ex 3: Find the decimal equivalent of the
8bit 2 s complement value 110010002
RZ?B6Two s Complement to Decimal(~Ex 3, Step 2: Find first one bit, from loworder (right) end, and complement the pattern to the left.
11001000~GWGgG$G((C6Two s Complement to Decimal(Ex 3, Step 3: Determine the numeric value:
001110002 = 32 + 16 + 8 = 5610
So: 110010002 = 5610 (8bit 2's complement form) ($$$$$$$$$$$&S/M problems solved with 2s complement''(
>Two s Complement Representation (Biggest reason two s complement used in most systems today?
The binary codes can be added and subtracted as if they were unsigned binary numbers, without regard to the signs of the numbers they actually represent.
*>Two s Complement Representation (]For example, to add +4 and 3, we simply add the corresponding binary codes, 0100 and 1101:
F^Z[GgGTwos Complement Representation(DLikewise, to subtract +7 from +3:
0011 (+3)
 0111 (+7)
1100 (4)
NOTE: A phantom 1 was borrowed from beyond the leftmost position.Z"GgGgGGGGgGgE>Two s Complement Representation ( Summary  Benefits of Twos Complements:
Addition and subtraction are simplified in the two scomplement system,
0 has been eliminated, replaced by one extra negative value, for which there is no corresponding positive number. F) P P()Valid RangesFor any integer data representation, there is a LIMIT to the size of number that can be stored.
The limit depends upon number of bits available for data storage.J=7*Unsigned Integer RangesRange = 0 to (2n 1)
where n is the number of bits used to store the unsigned integer.
Numbers with values GREATER than (2n 1) would require more bits. If you try to store too large a value without using more bits, OVERFLOW will occur.ckcccc:cc!cckcmcC(Unsigned Integer RangeszExample: On a system that stores unsigned integers in 16bit words:
Range = 0 to (216 1)
= 0 to 65535
Therefore, you cannot store numbers larger than 65535 in 16 bits.Ey!FaaiaaaaCaADy+Signed S/M Integer RangesRange = (2(n1) 1) to +(2(n1) 1)
where n is the number of bits used to store the sign/magnitude integer.
Numbers with
!"#$%&'()*+,./012345678 values GREATER than +(2(n1) 1) and values LESS than (2(n1) 1) would require more bits. If you try to store too large/too small a value without using more bits, OVERFLOW will occur.w
aiaiaaacc@ccc$c$"cckccckcvcb@,S/M Integer RangesExample: On a system that stores unsigned integers in 16bit words:
Range = (215 1) to +(215 1)
= 32767 to +32767
Therefore, you cannot store numbers larger than 32767 or smaller than 32767 in 16 bits.F%Ecc c k c k c c c c c Yc,D.Two s Complement RangesRange = 2(n1) to +(2(n1) 1)
where n is the number of bits used to store the twos complement signed integer.
Numbers with values GREATER than +(2(n1) 1) and values LESS than 2(n1) would require more bits. If you try to store too large/too small a value without using more bits, OVERFLOW will occur.{c k
c k c c c ccIccc$c$"cckccckcwcC ..Two s Complement RangesExample: On a system that stores unsigned integers in 16bit words:
Range = 215 to +(215 1)
= 32768 to +32767
Therefore, you cannot store numbers larger than 32767 or smaller than 32768 in 16 bits.F%Fcc
c k c k c c c c c YcD1"Using Ranges for Validity CheckingOnce you know how small/large a value can be stored in n bits, you can use this knowledge to check whether you answers are valid, or cause overflow.
Overflow can only occur if you are adding two positive numbers or two negative numbers
@
2"Using Ranges for Validity Checking6Ex 1:
Given the following 2 s complement equations in 5 bits, is the answer valid?
11111 (1) Range =
+11101 (3) 16 to +15
11100 (4) VALID
T
J"Using Ranges for Validity Checking>Ex 2:
Given the following 2 s complement equations in 5 bits, is the answer valid?
10111 (9) Range =
+10101 (11) 16 to +15
01100 (20) INVALID
T
!!!NFloating Point Numbers<
OFloating Point NumbersNow you've seen unsigned and signed integers. In real life we also need to be able represent numbers with fractional parts (like: 12.5 & 45.39). ` KpPFloating Point NumbersIn the decimal system, a decimal point (radix point) separates the whole numbers from the fractional part
Examples:
37.25 ( whole = 37, fraction = 25/100)
123.567
10.12345678
`uB)QFloating Point Numbers For example, 37.25 can be analyzed as:
101 100 101 102
Tens Units Tenths Hundredths
3 7 2 5
37.25 = (3 x 10) + (7 x 1) + (2 x 1/10) + (5 x 1/100)
l&GgGOGOGOGOo"GgGG6GgGRBinary Equivalence The binary equivalent of a floating point number can be determined by computing the binary representation for each part separately.
: 2(2SNFractional Part Multiplication Method(( 4 In the binary representation of a floating point number the column values will be as follows:
& 25 24 23 22 21 20 . 21 22 23 24 &
& 32 16 8 4 2 1 . 1/2 1/4 1/8 1/16&
& 32 16 8 4 2 1 . .5 .25 .125 .0625&
^33339<, TNFractional Part Multiplication Method(( Ex 1. Find the binary equivalent of 0.25
Step 1: Multiply the fraction by 2 until the fractional part becomes 0 .25
x 2
0.5
x 2
1.0
ZZG!G
GGG)GCGgGGgGGGGGgCGGCG(UNFractional Part Multiplication Method(( Ex 2. Find the binary equivalent of 0.625
Step 1: Multiply the fraction by 2 until the fractional part becomes 0 .625
x 2
1.25
x 2
0.50
x 2
1.0
PZZG!GGGG)GCG gGGg
GGGGGg
CGGGGGGGGCG5VHFractional Part Subtraction Method%% Start with the column values again, as follows:
& 20 . 21 22 23 24 25 26&
& 1 . 1/2 1/4 1/8 1/16 1/32 1/64&
& 1 . .5 .25 .125 .0625 .03125 .015625&
"3333
25WWHFractional Part Subtraction Method%% Starting with 0.5, subtract the column values from left to right. Insert a 0 in the column if the value cannot be subtracted or 1 if it can be. Continue until the fraction becomes .0
Ex 1.
.25 .5 .25 .125 .0625
 .25 .0 1
.0
Z@ZGG33GGG
GGgG33XBinary Equivalent of FP numberEx 2. Convert 37.25, using subtraction method.
64 32 16 8 4 2 1 . .5 .25 .125 .0625
26 25 24 23 22 21 20 . 21 22 23 24
0G*GgC G33G!G33O33G33O33G33O33G33O33G33O33G33O33G33O33G33G!G33O33G33O33G33O33G33O33 CGWYYBinary Equivalent of FP numberPEx 3. Convert 18.625, using subtraction method.
64 32 16 8 4 2 1 . .5 .25 .125 .0625
26 25 24 23 22 21 20 . 21 22 23 24
1 0 0 1 0 1 0 1
18 .625
 16  .5
2 .125
 2  .125
0 01ZxZ0ZxZG,GgC G33G!G33O33G33O33G33O33G33O33G33O33G33O33G33O33G33G!G33O33G33O33G33O33G33O33/GG'
'X\Problem storing binary formWe have no way to store the radix point!
Standards committee came up with a way to store floating point numbers (that have a decimal point) P]"IEEE Floating Point Representation##$Floating point numbers can be stored into 32bits, by dividing the bits into three parts:
the sign, the exponent, and the mantissa.
Z 2.(2`
%^"IEEE Floating Point Representation##$The first (leftmost) field of our floating point representation will STILL be the sign bit:
0 for a positive number,
1 for a negative number.
]3[EGG2G$g$g$6\_Storing the Binary FormHow do we store a radix point?
 All we have are zeros and ones&
Make sure that the radix point is ALWAYS in the same position within the number.
Use the IEEE 32bit standard
the leftmost digit must be a 1
BT!`Solution is Normalization% Every binary number, except the one corresponding to the number zero, can be normalized by choosing the exponent so that the radix point falls to the right of the leftmost 1 bit.
37.2510 = 100101.012 = 1.0010101 x 25
7.62510 = 111.1012 = 1.11101 x 22
0.312510 = 0.01012 = 1.01 x 22z&Z/94
!a"IEEE Floating Point Representation##$
The second field of the floating point number will be the exponent.
The exponent is stored as an unsigned 8bit number, RELATIVE to a bias of 127.
Exponent 5 is stored as (127 + 5) or 132
132 = 10000100
Exponent 5 is stored as (127 + (5)) or 122
122 = 01111010 )  :F
)! !bTry It YourselfkHow would the following exponents be stored (8bits, 127biased):
210
28
(Answers on next slide)
B! ) ! BaaiaieaAcAnswers 210
exponent 10 8bit
bias +127 value
117 01110101
28
exponent 8 8bit
bias +127 value
135 10000111 !)!%!!!%
!%!)!%!!!%
!%d"IEEE Floating Point Representation##$The mantissa is the set of 0 s and 1 s to the right of the radix point of the normalized (when the digit to the left of the radix point is 1) binary number.
Ex: 1.00101 X 23
(The mantissa is 00101)
GGBG
GFGG"G"!G"O"O"EG$e2Decimal Floating Point toIEEE standard Conversion"32 " Ex 1: Find the IEEE FP representation of 40.15625
Step 1.
Compute the binary equivalent of the whole part and the fractional part. (i.e. convert 40 and .15625 to their binary equivalents) G3GgG\GGGGGG Cf2Decimal Floating Point toIEEE standard Conversion33 40 .15625
 32 Result: .12500 Result:
8 101000 .03125 .00101
 8 .03125
0 .0
So: 40.1562510 = 101000.001012
ZGgGGFFGGGF GG
GGGGGg
GgGgFF N F F N Ff'g2Decimal Floating Point toIEEE standard Conversion33 Step 2. Normalize the number by moving the decimal point to the right of the leftmost one.
101000.00101 = 1.0100000101 x 25
]'GVGgG
G G G O o G g h2Decimal Floating Point toIEEE standard Conversion33 Step 3. Convert the exponent to a biased exponent
127 + 5 = 132
And convert biased exponent to 8bit unsigned binary:
13210 = 100001002
ZG,Gg GGJGOGGOgGgi2Decimal Floating Point toIEEE standard Conversion33 Step 4. Store the results from steps 13:
Sign Exponent Mantissa
(from step 3) (from step 2)
0 10000100 01000001010000000000000
~G&G9G0Gg j2Decimal Floating Point toIEEE standard Conversion33 Ex 2: Find the IEEE FP representation of 24.75
Step 1. Compute the binary equivalent of the whole part and the fractional part.
24 .75
 16 Result:  .50 Result:
8 11000 .25 .11
 8  .25
0 .0
So: 24.7510 = 11000.112
ZfZ 8Z2ZG'GGGgGMGgGgGGG GgGG
GGgGGGgGg '', k2Decimal Floating Point toIEEE standard Conversion33 Step 2.
Normalize the number by moving the decimal point to the right of the leftmost one.
11000.11 = 1.100011 x 24
GXGgEMeEel3Decimal Floating Point toIEEE standard Conversion. 42 Step 3. Convert the exponent to a biased exponent
127 + 4 = 131
==> 13110 = 100000112
Step 4. Store the results from steps 13
Sign Exponent mantissa
1 10000011 1000110..0
@2ZZZG+Gg!GOGOgGG?GGgGo4IEEE standard to Decimal Floating Point Conversion. 53 Do the steps in reverse order
In reversing the normalization step move the radix point the number of digits equal to the exponent:
If exponent is positive, move to the right
If exponent is negative, move to the leftfUGgfGGGGGG GGGGp4IEEE standard to Decimal Floating Point Conversion. 53 Ex 1: Convert the following 32bit binary number to its decimal floating point equivalent:
Sign Exponent Mantissa
1 01111101 010..0
6]ZBZGXGgGgGgGGgGgGgq5IEEE standard to Decimal Floating Point Conversion.. 63 Step 1: Extract the biased exponent and unbias it
Biased exponent = 011111012 = 12510
Unbiased Exponent: 125 127 = 2
G+GgGEMEEME&EE$'Vr5IEEE standard to Decimal Floating Point Conversion.. 63 Step 2: Write Normalized number in the form:
1 . ____________ x 2 
For our number:
1. 01 x 2 2
wZG(GGGOGGGGOggGgks4IEEE standard to Decimal Floating Point Conversion. 53 *Step 3: Denormalize the binary number from step 2 (i.e. move the decimal and get rid of (x 2n) part):
0.01012 (negative exponent move left)
GWGOGgGG O G GGG$ t4IEEE standard to Decimal Floating Point Conversion. 53 Ex 2: Convert the following 32 bit binary number to its decimal floating point equivalent:
Sign Exponent Mantissa
0 10000011 10011000..0
[7GZGGGGGGgGGgEeu5IEEE standard to Decimal Floating Point Conversion.. 63 Step 1: Extract the biased exponent and unbias it
Biased exponent = 10000112 = 13110
Unbiased Exponent: 131 127 = 4
G+GgGEMEEME&EEE'Vv5IEEE standard to Decimal Floating Point Conversion.. 63 tStep 2: Write Normalized number in the form:
1 . ____________ x 2 
For our number:
1.10011 x 2 4
uG'GEEEMEEEG$
G$O$o$w4IEEE standard to Decimal Floating Point Conversion. 53 Step 4: Convert binary number to the FP equivalent (i.e. Add all column values with 1s in them)
11001.1 = 16 + 8 + 1 +.5
= 25.510a/(G[GG"G G$O$G$/pPr~=d
Z=1)CRoot EntrydO)@X҆@Current User<>SummaryInformation("PowerPoint Document(e)
!"#$%&'()*+,./012345678
!"#$%&'()*+,./0123456789:;<=>?@ABCDEFGHPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{}~
!"#$%&'()*+,./0123456789:;rd to Decimal Floating Point Conversion..5IEEE standard to Decimal Floating Point Conversion.Fonts UsedDesign Template
Slide TitlesV"_A)
Insight110Insight110wood
>O