Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
Discrete Maths 2002 Lecture 07 3 Slides Pp

Discrete Maths 2002 Lecture 07 3 Slides Pp

|Views: 4|Likes:
Published by api-3718916

More info:

Published by: api-3718916 on Oct 15, 2008
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





Lecture 7, 6-August-2002
Discrete Mathematics 2002
Computer Repn of Real Numbers
\u2022 Last lecture: We started to look at how real
numbers are stored in a computer
\u2022 Computer repns are based on thenor malised
binary exponential formof the real number
\u2022 A no. is in normalised binary exponential form

(nbe form) if it is expressed as\u00b1m \u00d7 2e, where:
significandm is a binary no. with 0.12\u2264m < 1,
exponente is a decimal integer

\u2022 Thus 1101.012is not in nbe form, but it can be
written in nbe form as 0.1101012\u00d724
Storing a Real Number
\u2022 Normalised form is used to ensure the repn of a
real no. isuniq ue (i.e. a no. has onlyone repn)
\u2022 A real no. is typically stored in a computer in 4 or
8 bytes (32 or 64 bits) \u2013 called single precision &
double precisionif both are available
\u2022 1st bit is the sign bit, and the remaining bits are
divided between exponent and significand
\u2022 The no. of bits for the exponent determines the
rangeof nos that can be stored
\u2022 The no. of bits for the significand determines the
precisionwith which nos can be stored
The Characteristic
\u2022 For a fixed no. of bits, there has to be a
trade-off between range and precision
\u2022 With 4 bytes, a common format is 8 bits for
the exponent and 23 bits for the significand

\u2022 Usually the exponent itself is not stored, but
thecharacteristic \u2013 this is obtained by
adding the exponent bias to the exponent

\u2022 Typically the bias is 2n\u20131\u2013 1, wheren = no.
of bits available to store the characteristic
\u2022 So ifn = 8, a typical exponent bias is 27\u2013 1
Lecture 7, 6-August-2002
Discrete Mathematics 2002
The Characteristic (continued)

\u2022 The exponent is stored as the characteristic to
allow simpler methods for the computer to
perform arithmetic with real nos

\u2022 This is similar to integer arithmetic being simpler
if negative nos are stored as 2\u2019s complements
Examples and Summary
\u2022 Examples: Find 32-bit repns, if 8 bits are used
for the characteristic and exp bias is 27\u2013 1:
(a): 0.1011101012\u00d724
Ans: 01000001110111010100000000000000
(b): 0.1111012\u00d7 2\u20135
Ans: 00111101011110100000000000000000
\u2022 Summary: To find the repn of a real number:
(1): Convert the number to binary, with precision

determined by the no. of bits for the significand
(2): Convert to normalised binary exp form
(3): Calculate the characteristic
(4): Write down the computer repn

Example of Computer Repn

\u2022 Example: Find the 32-bit repn of \u20132365.66, if
8 bits are used for the characteristic, and the
exponent bias is 27\u2013 1. Note that
\u20132365.66 = \u2013100100111101.10101000111\u20262

Ans: 11000101110010011110110101000111

\u2022 Note: This example shows that the computer repn of a real no. may not be exact (because the binary conversion is truncated)

\u2022 This contrasts with integers, which are stored
and manipulatedexactly in a computer
Lecture 7, 6-August-2002
Discrete Mathematics 2002
Computer Repns and Exactness

\u2022 As shown in the example, the computer repn of a real no. mayno t be exact (because the significand is truncated to the available no. of bits)

\u2022 Also, round-off errors can occur in computer
arithmetic with real nos (just as on a calculator \u2013
e.g. if 10 digits are shown, you won\u2019t obtain the
exact answer to 300000 + 0.000005)

\u2022 Thus, for example, care is needed in a computer
program if testing whether 2 real nos are equal
What Range of Real Nos can be
Stored in a Computer?
\u2022 Assume real nos are stored in 32 bits, with 8
bits for the char & exp bias of 27\u2013 1 = 127
\u2022 Then the characteristic can have values from

000000002to1 111111 12(i.e. 0 to 255)
\u2022 So the exponent is between \u2013127 & 128
\u2022 The significand ranges from 0.12 (which is 0.5

in decimal) to 0.111\u2026.1112(i.e. 23 ones)
\u2022 This latter no. isextre mely close to 1
Range of Real Nos (continued)

\u2022 Thus the range of positive nos that can be represented is from 0.5\u00d7 2\u2013127to (almost) 1\u00d7 2128, which is from 2\u2013128to 2128

\u2022 In decimal exponential form, this range is
from about 0.294\u00d7 10\u201338to 0.340\u00d7 1039

\u2022 Likewise, the range of negative nos (which have a sign bit of 1) is from \u20130.294\u00d7 10\u201338 to \u20130.340\u00d7 1039

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->