• Aucun résultat trouvé

F L O A T IN G P O IN T N U M B E R S E n g la n d er C h . 5 ITEC 1011Introduction to Information Technologies

N/A
N/A
Protected

Academic year: 2022

Partager "F L O A T IN G P O IN T N U M B E R S E n g la n d er C h . 5 ITEC 1011Introduction to Information Technologies "

Copied!
7
0
0

Texte intégral

(1)

F L O A T IN G P O IN T N U M B E R S E n g la n d er C h . 5

ITEC 1011Introduction to Information Technologies

E x p o n en ti al N o ta ti o n

The representations differ in that the decimal place the “point”--“floats”to the left or right (with the appropriate adjustment in the exponent).

• T h e fo ll o w in g a re e q u iv al en t re p re se n ta ti o n s o f 1 ,2 3 4

123,400.0x10-2 12,340.0x10-1 1,234.0x100 123.4x101 12.34x102 1.234x103 0.1234x104 ITEC 1011Introduction to Information Technologies

P ar ts o f a F lo at in g P o in t N u m b er - 0 . 9 8 7 6 x 1 0

-3 Sign of mantissaLocation of decimal pointMantissa

Exponent Sign of exponent Base

E x p o n en t E x ce ss 5 0 R ep re se n ta ti o n

W it h 2 d ig it s fo r th e ex p o n en t an d 5 f o r th e m a n ti ss a: f ro m . 0 0 0 0 1 x 1 0

-50

to . 9 9 9 9 9 x 1 0

49

(2)

O v er fl o w s / U n d er fl o w s

F ro m .0 0 0 0 1 x 1 0

-50

to . 9 9 9 9 9 x 1 0

49

1 x 1 0

-55

to . 9 9 9 9 9 x 1 0

49

T y p ic al F lo at in g P o in t F o rm at

EC 1011Introduction to Information Technologies

IE E E 7 5 4 S ta n d ar d

Most common standard for representing floating point numbers Single precision: 32 bits, consisting of... •Sign bit (1 bit) •Exponent (8 bits) •Mantissa (23 bits) Double precision: 64 bits, consisting of… •Sign bit (1 bit) •Exponent (11 bits) •Mantissa (52 bits) ITEC 1011Introduction to Information Technologies

S in g le P re ci si o n F o rm at

32 bits Mantissa (23 bits) Exponent (8 bits) Sign of mantissa (1 bit)

(3)

ITEC 1011Introduction to Information Technologies

D o u b le P re ci si o n F o rm at

64 bits Mantissa (52 bits) Exponent (11 bits) Sign of mantissa (1 bit) ITEC 1011Introduction to Information Technologies

N o rm al iz at io n • T h e m an ti ss a is

normalized

• H as a n i m p li ed d ec im a l p la ce o n l ef t • H as a n i m p li ed “ 1 ” o n l ef t o f th e d ec im al p la ce • E .g .,

•Mantissa: •Representation:

1010000000000000000000 1.1012=1.62510 ITEC 1011Introduction to Information Technologies

E x ce ss N o ta ti o n

•To include both positive and negative exponents, “excess-n”notation is used •Single precision: excess 127 •Double precision: excess 1023 •The value of the exponent stored is nlarger than the actual exponent •E.g., –excess 127, •Exponent: •Representation:

10000111 135127=8(value) ITEC 1011Introduction to Information Technologies

E x ce ss N o ta ti o n

-Sample - Represent exponent of 1410in excess 127 form: 12710= + 011111112 1410= +000011102 Representation=100011012

(4)

EC 1011Introduction to Information Technologies

E x ce ss N o ta ti o n

-Sample - Represent exponent of -810in excess 127 form: 12710= + 011111112 -810= -000010002 Representation=011101112 ITEC 1011Introduction to Information Technologies

E x am p le • S in g le p re ci si o n

01000001011000000000000000000000 1.112= 1.7510 130127 = 3 0 = positive mantissa +1.75×23= 14.0 EC 1011Introduction to Information Technologies

E x er ci se – F lo at in g P o in t C o n v er si o n ( 1 ) • W h at d ec im al v al u e is r ep re se n te d b y t h e fo ll o w in g 3 2 -b it f lo at in g p o in t n u m b er ? • A n sw er :

11000001011110110000000000000000 Skip answerAnswer ITEC 1011Introduction to Information Technologies

E x er ci se – F lo at in g P o in t C o n v er si o n ( 1 ) • W h at d ec im al v al u e is r ep re se n te d b y t h e fo ll o w in g 3 2 -b it f lo at in g p o in t n u m b er ? • A n sw er : -1 5 .6 8 7 5

11000001011110110000000000000000

Answer

(5)

ITEC 1011Introduction to Information Technologies

11000001011110110000000000000000 To decimal form 130 -127 = 31.11110110000000000000000000 1 + .5 + .25 + .125 + .0625 + 0 + .015625 + .0078125 1.960937523 *= 15.6875

- 1 5 .6 8 7 5

( negative )

S te p b y S te p S o lu ti o n

ITEC 1011Introduction to Information Technologies

11000001011110110000000000000000 To decimal form 130 -127 = 31.11110110000000000000000000 1111.10110000000000000000000

- 1 5 .6 8 7 5

( negative )

Shift “Point”

Step by Step Solution : Alternative Method ITEC 1011Introduction to Information Technologies

E x er ci se – F lo at in g P o in t C o n v er si o n ( 2 ) • E x p re ss 3 .1 4 a s a 3 2 -b it f lo at in g p o in t n u m b er

•Answer: •(Note: only use 10 significant bits for the mantissa) Skip answerAnswer

E x er ci se – F lo at in g P o in t C o n v er si o n ( 2 ) • E x p re ss 3 .1 4 a s a 3 2 -b it f lo at in g p o in t n u m b er

•Answer:

Answer 01000000010010001111010111000010

(6)

3.14 To Binary:11. 0010001111010111000010 Delete implied left-most1 and normalize10010001111010111000010 Exponent = 127 + 1 position point moved when normalized10000000 Value is positive: Sign bit = 0 0 1000000010010001111010111000010

Poof !

Detail Solution : 3.14 to IEEE Simple Precision

IE E E S in g le -P re ci si o n F lo at in g P o in t F o rm at

E x p o n en t b ia s is 1 2 7 f o r n o rm al iz ed # s

e e Value Type 255 nonenoneInfinity or NaN 254 127 (-1)s××××(1.f1f2...)××××2127Normalized ... ... ... ... 2 -125 (-1)s××××(1.f1f2...)××××2-125Normalized 1 -126 (-1)s××××(1.f1f2...)××××2-126Normalized 0 -126 (-1)s××××(0.f1f2...)××××2-126Denormalized

^

sê

f 1 f 2

. . . f23

signexponentfraction 189310

D ec im al F lo at in g -P o in t A d d a n d S u b tr ac t E x am p le s

OperandsAlignmentNormalize & round 6.144××××1020.06144××××1041.003644××××105 +9.975××××104+9.975 ××××104+ .0005 ××××105 10.03644××××1041.004 ××××105 OperandsAlignmentNormalize & round 1.076××××10-71.076 ××××10-77.7300 ××××10-9 -9.987××××10-8-0.9987××××10-7+ .0005 ××××10-9 0.0773××××10-77.730 ××××10-9

F lo at in g P o in t C al cu la ti o n s: A d d it io n

•Numbers must be aligned: have the same exponent (the larger one, to protect precision) •Add mantissas. If overflow, adjust the exponent •Ex. 0 51 99718 (e = 1) and 0 49 67000 (e = -1) Align numbers:0 51 99718 0 51 00670 Add them:99718 +00670 100388Overflow Round the number and adjust exponent: 0 52 10039

(7)

F lo at in g P o in t C al cu la ti o n s: M u lt ip li ca ti o n

•(a * 10^e) * (b * 10^f) = a * b * 10^(e+f) •Rule: multiply mantissas; add exponents But:(n + e) + (n + f) = 2 * (n + e + f) Must subtract excess n from result •Ex. 0 51 99718 (e = 1) and 0 49 67000 (e = -1) Mantissas:.99718 * .67000 = 0.6681106 Exponents:51 + 49 = 100 and100 50 = 50 Normalize:.6681106 .66811 Final result:.66811 * 100(since 50 meanse = 0)

Références

Documents relatifs

Rapport entre le nombre de décès d'enfants de moins d'un an, enregistrés pendant une période donnée (en général une année) et dans un lieu donné, et les naissances vivantes de

[r]

5 Que font Sami et Julie quand le match est terminé.. Tobi ne veut pas voir

This is not true for Hermitian holomorphic vector bundles, in general (cf. There are several ways in which we could generalize our results. Now while our

Due to their general philosophical character these investigations of Hjelmslev created great interest beyond the sphere of the mathematicians.. Naturally different

Die anonym elnzureichendeu Bewerbungsschriften sind in deutscher, lateinischer oder franzb'sischer Sprache zu verfassen~ miissen deutlich geschrieben und pagi~irt,

Later on the identity (6) was used to obtain estimates from below for analytic capacity [Me] and to describe uniform rectifiability via the mapping properties

construct a reflexive sheaf from Y using the Serre construction, and then to describe this sheaf by means of a monad, where the family of monads involved