CA Lecture 3: Data Representation II - PowerPoint PPT Presentation

1 / 31
About This Presentation
Title:

CA Lecture 3: Data Representation II

Description:

If the mantissa is represented as a binary, then there is always a leading '1' ... 4c) What is the smallest positive normalized mantissa if the hidden 1 is to the ... – PowerPoint PPT presentation

Number of Views:178
Avg rating:3.0/5.0
Slides: 32
Provided by: spa951
Category:

less

Transcript and Presenter's Notes

Title: CA Lecture 3: Data Representation II


1
CA Lecture 3 Data Representation (II)
  • Floating Point Numbers and Character Code
  • (Chapter 2 of text book)

2
Disadv. of fixed point number representation
  • The disadvantage of fixed point numbers need a
    great many digits to represent a practical range
    of numbers as in practice, very large and very
    small numbers can appear in any computation. E.g.
  • To represent a number as large as a trillion2,
    the computer needs at least 40 bits to the left
    of the radix point since 240 1012.

3
Disadv. of fixed point number representation
cont.
  • If the same computer needs to represent one
    trillionth, then 40 bits must also be maintained
    on the right of the radix point. Thus 80 bits are
    needed per number!
  • A great deal of hardware (e.g. wires) is required
    to store and manipulate numbers with 80 or more
    bits of precision, and the speed of computation
    would also be slower.

4
Floating Point Numbers
  • Fine precision is generally not needed when large
    numbers are used, and large numbers do not
    generally need to be represented when
    calculations are made with small numbers.
  • An efficient computer can be realized when only
    as much precision is retained as is needed.
  • Floating point numbers allow very large and
    very small numbers to be represented using only a
    few digits, at the expense of precision.

5
Base 10 Floating Point Numbers (FPN)
  • The precision is determined by the number of
    digits in the fraction 6.023 (or significand or
    mantissa which has integer and fractional parts).
  • The range (represented by a power of 10, 1023) is
    determined by the number of digits in the
    exponent.

6
Range and Precision in FPN
  • A floating point number can be characterized by
    a triple of numbers sign, exponent, and
    significand.
  • The ordering (sign bit, exponent, then
    significand) is helpful in comparing two floating
    point numbers.
  • The range/precision trade-off is a major
    advantage of using a floating point
    representation.

7
Normalization
  • The same number can be represented in different
    floating point forms
  • (3584.1)10 100 (3.5841)10 103
    (0.35841)10 104

  • (35.841)10 102
  • Floating point numbers are usually normalized,
    in which the radix point is located in only one
    possible position for a given number.
  • Usually, the normalized representation places
    the radix point immediately to the left or right
    of the leftmost, nonzero digit in the fraction,
    as in (0.35841)10 104 or (3.5841)10 103

8
Normalization and The Hidden Bit in base 2
  • Number zero cannot be represented in the
    normalized form. Thus zero is represented as all
    0s in the mantissa/significand.
  • If the mantissa is represented as a binary,
    then there is always a leading 1 in the
    normalized mantissa, so there is no need to store
    that 1. E.g.
  • (110.10)2 x 22 (0.11010)2 25 (1.1010)2
    24
  • This missing bit is referred to as the hidden
    bit, also known as a hidden 1.

9
Hidden Bit
  • For the above example
  • If normalized representation places the binary
    point immediately to the left of the leftmost,
    nonzero digit in the fraction, then normalized
    mantissa 0.11010 will be stored in bit pattern
    1010.
  • If normalized representation places the binary
    point immediately to the right of the leftmost,
    nonzero digit in the fraction, then normalized
    mantissa 01.1010 will be stored in bit pattern
    1010.

10
Representing FPN in a Computer
  • Assume a computer represents floating point
    numbers in this ordering of packing the sign
    bit, 3-bit excess 4 exponent, 3 hexadecimal (base
    16) digits of significand.
  • The normalized form places the radix point
    immediately to the left of the leftmost , nonzero
    digit in the fraction.
  • The hexadecimal point will NOT be stored.
  • Consider representing (358.0)10 in this format.
  • 1st step convert the fixed point number from its
    original base into a fixed point number in the
    target base (base 16). Thus (358.0)10 (166.0)16

11
Representing FPN in The Computer Cont.
  • 2nd step normalize the number. Thus
  • (166.)16 X 160 (.166)16 X 163
  • 3rd step convert mantissa into a binary
    pattern. (166)16 (0001 0110 0110)2
  • 4th step work out the exponent in excess 4 gt
    (3 4 7)10 (111)2
  • 5th step fill in the bit fields, with a
    positive sign (sign bit 0), and the rest
  • 0 111 . 0001 0110 0110

12
Another floating point example
13
Another floating point example cont.
14
Reason for the use of excess 4 exponent in FPR
  • The use of an excess 4 exponent instead of a 2s
    complement or a signed magnitude exponent
    simplifies comparison, addition and subtraction
    of floating point numbers.
  • FPN arithmetic will be covered in the next
    lecture.

15
The IEEE 754 Floating Point Standard
  • IEEE stands for Institute of Electrical and
    Electronics Engineers.
  • The IEEE 754 is an international standard for
    floating point numbers.
  • The IEEE 754 standard must be supported by a
    computer system.
  • The IEEE 754 standard can be supported by the
    hardware entirely, or can be supported by a
    mixture of hardware and software.

16
The IEEE 754 Cont.
  • There are two primary formats in the IEEE 754
    standard single precision and double precision.
  • Both single and double formats are in base 2.
  • Uses hidden bit.
  • The single-precision format occupies 32 bits.
  • The double-precision format occupies 64 bits.
  • Normalization binary point is on the right
    side of the leftmost non-zero digit.

17
The IEEE 754 Cont.
18
Single Precision Format
  • The sign bit is on the leftmost position and
    indicates a positive or negative number for a 0
    or a 1, respectively.
  • The 8-bit excess 127 exponent follows. Bit
    patterns 00000000 and 11111111 are reserved for
    special cases.
  • The 23-bit base 2 fraction follows.
  • A hidden bit is to the left of the binary
    point. Totally there are 12324-bit significand.

19
Double Precision Format
  • The sign bit is the same as in SPF.
  • The 11-bit excess 1023 exponent follows. Again,
    all 0s and all 1s are reserved for special
    cases.
  • The 52-bit base 2 fraction follows.
  • A hidden bit is to the left of the binary
    point. Totally there are 15253-bit significand.
  • The number is normalised unless denormalised
    numbers are supported.

20
The IEEE 754 - Cont.
  • A so-called clean zero is represented by the
    reserved bit pattern 00000000 in the exponent and
    all 0s in the fraction. The sign bit can be 0 or
    1. Thus there are 2 representations for zero.
  • Infinity has a representation in which the
    exponent contains the reserved bit pattern
    11111111, the fraction contains all 0s, and the
    sign bit can be 0 or 1.
  • A zero number divided by a zero will produce
    NaN (Not a number).
  • In a NaN, the exponent contains the reserved
    bit pattern 11111111, the fraction is nonzero,
    and the sign bit can be 0 or 1.

21
IEEE-754 Examples
22
IEEE-754 Conversion Example
  • Represent -12.62510 in single precision
    IEEE-754 format.
  • Step 1 Convert to target base. -12.62510
    -1100.1012
  • Step 2 Normalize. -1100.1012 -1.1001012 X
    23
  • Step 3 Fill in bit fields. Sign is negative,
    so sign bit is 1. Exponent is in excess 127 (not
    excess 128!), so exponent is represented as the
    unsigned integer 3 127 130. Leading 1 of
    significand is hidden, so final bit pattern is
  • 1 1000 0010 . 1001 0100 0000 0000 0000 000

23
The ASCII Character Set
  • The American Standard Code for Information
    Interchange (ASCII) is a 7-bit code, commonly
    stored in 8-bit bytes.
  • The characters in positions 00-1F and position
    7F are special control characters.

24
The ASCII Character Set
25
The Unicode Character Set
  • Unicode is a 16-bit coding.
  • Unicode supports a great breadth of the worlds
    character sets.
  • Unicode is an evolving (or changing) standard.

26
The Unicode Character Set
27
Tutorial Two Questions
  • 1. For the following single-precision IEEE 754
    bit patterns show the numerical value as a base 2
    significand with an exponent
  • (a) 0 10000011 01100000000000000000000
  • (b) 1 10000000 00000000000000000000000
  • (c) 1 00000000 00000000000000000000000
  • (d) 1 11111111 00000000000000000000000
  • (e) 0 11111111 11010000000000000000000
  • (f) 0 00000001 10010000000000000000000

28
Tutorial Two Questions
  • 2. Convert the following decimal numbers to IEEE
    single-precision floating point
  • 128
  • -32.75
  • 18.125
  • 0.0625

3. A hidden 1 representation will not work for
base 16. Why not?
29
Tutorial Two Questions
  • 4. Consider a system with the following
    floating point format 1 sign bit, followed by a
    3-bit exponent, followed by a 4-bit mantissa. The
    exponent is in twos complement. The magnitude of
    the mantissa is a fixed point number, with a
    hidden bit. Answer the following questions for
    this number system, giving answers in
    conventional decimal form
  • 4a)     What is the largest possible exponent?
  • 4b)     What is the largest possible mantissa if
    the hidden 1 is to the left of the binary point?

30
Tutorial Two Questions
  • 4c)      What is the smallest positive normalized
    mantissa if the hidden 1 is to the left of the
    binary point?
  • 4d)     What is the smallest positive normalized
    mantissa if the hidden 1 is to the right of the
    binary point?
  • 4e)      What is the smallest positive number in
    this system if the hidden 1 is to the left of the
    binary point?
  • 4f)       How many different numbers can be
    represented by the system?

31
Tutorial Two Questions
  • The IBM short floating point representation uses
    base 8, one sign bit, a seven-bit excess 64
    exponent, and a normalized 24-bit fraction.
    (Normalisation the point is on the left side of
    the leftmost non-zero digit.)
  • 5a. Represent (14.3)6 in this notation.
  • 5b. What number is represented by the following
    bit pattern?
  • 1 0111111 01110000 00000000 00000000
  • Show your answer in decimal. Note The spaces
    are included in the number for readability only.
Write a Comment
User Comments (0)
About PowerShow.com