Binary Real Numbers - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

Binary Real Numbers

Description:

Mantissa: normalized number. Exponent: power to which the ... Mantissa (# bits varies) Exponent ... 2s complement the mantissa by flipping bits and adding 1: ... – PowerPoint PPT presentation

Number of Views:174
Avg rating:3.0/5.0
Slides: 14
Provided by: paul181
Category:

less

Transcript and Presenter's Notes

Title: Binary Real Numbers


1
Binary Real Numbers
2
Introduction
  • Computers must be able to represent real numbers
    (numbers w/ fractions)
  • Two different ways
  • Fixed-point
  • Floating-point
  • NOTE Everything in binary uses powers of two

3
Decimal Review
  • Digits to the right of the decimal point
    correspond to negative powers of 10

4
Binary Fractions
5
Fixed Point Notation
  • Multiply each 1 by the corresponding power of 2
  • Add up the resulting powers of 2
  • Example
  • 11.012 2 1 ¼ 3.2510
  • 00111.0102 4 2 1 ¼ 7.2510

6
Floating-Point Notation
  • Floating-point notation is essentially the
    computers way of storing a number that has been
    normalized
  • 3 different parts of any number
  • Mantissa normalized number
  • Exponent power to which the base is raised
  • Sign of both mantissa and exponent
  • Decimal Example
  • 12.5 0.125 x 102 ? normalized!

7
Normalization Steps
  • Beginning with a fixed point number
  • Normalize the number such that the radix point
    (decimal point) is all the way to the left
    (produces the mantissa)
  • Multiply the resulting number by the base raised
    to an exponent

8
Floating-Point Example
  • What is 12.5 in floating-point representation?
  • Convert 12.5 to binary fixed point
  • 12.510 1100.12
  • Normalize the number by moving the radix point,
    producing the mantissa
  • 1100.12 0.11001 24
  • Fill in the bits for each of the three parts of
    any real number
  • Sign (2 bits)
  • Mantissa ( bits varies)
  • Exponent ( bits varies)
  • NOTE 2s complement may be applied to the
    mantissa or the exponent if either are negative

9
Placing the Bits
  • Assume you have the following
  • 1 bit for the mantissa sign
  • 8 bits for the mantissa
  • 1 bit for the exponent sign
  • 6 bits for the exponent
  • SM M M M M M M M M S E E E E E E E
  • Example
  • 0.11001 24 ? 0 00011001 0 000100

10
Another Example
  • Convert -12.510 to binary
  • Convert 12.5 to fixed point ? 01100.1
  • Normalize ? 0.11001 24
  • Convert exponent base to binary 4 ? 0100
  • 2s complement the mantissa by flipping bits and
    adding 1 011001 ? 100111
  • Final number ? 1 00111 0100

11
Upper Lower Bounds
  • Assume you have the following
  • 1 bit for the mantissa sign
  • 8 bits for the mantissa
  • 1 bit for the exponent sign
  • 6 bits for the exponent
  • What is the upper bound for the floating-point
    number?
  • What is the lower bound for the floating-point
    number?
  • What happens if we convert a floating-point
    number to an integer?

12
Integers vs. Floating-point
  • integers
  • smaller range than floating-point
  • all numbers within the range are 100 accurate
  • floating-point
  • large range of numbers
  • not all numbers within the range can be
    represented accurately
  • Example 2.9999999999999 repeating

13
Possible Errors
  • truncation error
  • round off errors using floating-point numbers
    because not all real numbers can be represented
    accurately
  • overflow error
  • attempting to represent a number that is greater
    than the upper bound for the given number of bits
  • underflow error
  • attempting to represent a number that is less
    than the lower bound for the given number of bits
Write a Comment
User Comments (0)
About PowerShow.com