Docsity

Floating Point Numbers: IEEE Standard and Conversion Examples, Study notes of Computer Architecture and Organization

Toggle sidebar
bg1
EECE 6278/4278
Handout#2
Spring’03
Floating Point Numbers
Introduction
The following ranges are available for integer numbers:
Storage Size Numeric Range
1 byte (character) (2^7 = 128) -128 to +127
2 bytes (short) (2^15 ) -32,768 to +32,767
4 bytes (integer) (2^32) -2,147,483,648 to +2,147,483,647
Floating point numbers are needed to cover a wider range than integers and also to separate the magnitude of a
number from its precision. In order to accomplish this, floating point uses scientific notation:
number = mantissa * 10^exponent
e.g.,
1,234,000 = 1.234 X 10^6
.005 = 5 X 10^-3
The number of digits in the mantissa reflects the precision and the size of exponent controls the range.
IEEE Floating Point Standard
Originally, computer manufacturers had their own standard, but now most adhere to the IEEE standard
which was released in the 1980's.
Three formats for numbers:
Single precision: 32 bits
Double precision: 64 bits
Extended precision: 80 bits
Number is divided into the following three parts:
Sign bit for overall number - 0 for positive and 1 for negative.
Exponent
Single Precision - 8 bits using excess 127 notation.
Double Precision - 11 bits using excess 1023 notation.
Fraction - Uses base 2 and normalized to lie between 1 and slightly less than 2 . The leading 1 and
the "binary" point are implied.
Single Precision - 23 bits
Double Precision - 52 bits
Denormalized numbers are used to represent small numbers; i.e. the range 0 to 1. These numbers have an
exponent of 0 and an implied 0. for the fraction piece.
Numeric Ranges:
Single Precision - approx. 10^-38 to 10^+38 (10^-45 for denormalized)
Double Precision - approx. 10^-308 to 10^+308 (10^-324 for denormalized)
Special Values:
Zero - There are two zeros, positive and negative.
Infinity - exponent of all 1's and and a fraction of 0.
NAN (Not a number, produced by dividing 0 by 0 or infinity by infinity) - exponent of all 1's and
any non-zero fraction.
Conversion Examples
Converting from decimal to IEEE floating point:
Convert 9 to floating point single precision:
pf2

Partial preview of the text

Download Floating Point Numbers: IEEE Standard and Conversion Examples and more Study notes Computer Architecture and Organization in PDF only on Docsity!

EECE 6278/

Handout#

Spring’

Floating Point Numbers

Introduction

The following ranges are available for integer numbers: Storage Size Numeric Range 1 byte (character) (2^7 = 128) -128 to + 2 bytes (short) (2^15 ) -32,768 to +32, 4 bytes (integer) (2^32) -2,147,483,648 to +2,147,483, Floating point numbers are needed to cover a wider range than integers and also to separate the magnitude of a number from its precision. In order to accomplish this, floating point uses scientific notation: number = mantissa * 10^exponent e.g., 1,234,000 = 1.234 X 10^ .005 = 5 X 10^- The number of digits in the mantissa reflects the precision and the size of exponent controls the range.

IEEE Floating Point Standard

 Originally, computer manufacturers had their own standard, but now most adhere to the IEEE standard which was released in the 1980's.  Three formats for numbers:  Single precision: 32 bits  Double precision: 64 bits  Extended precision: 80 bits  Number is divided into the following three parts:  Sign bit for overall number - 0 for positive and 1 for negative.  Exponent  Single Precision - 8 bits using excess 127 notation.  Double Precision - 11 bits using excess 1023 notation.  Fraction - Uses base 2 and normalized to lie between 1 and slightly less than 2. The leading 1 and the "binary" point are implied.  Single Precision - 23 bits  Double Precision - 52 bits  Denormalized numbers are used to represent small numbers; i.e. the range 0 to 1. These numbers have an exponent of 0 and an implied 0. for the fraction piece.  Numeric Ranges:  Single Precision - approx. 10^-38 to 10^+38 (10^-45 for denormalized)  Double Precision - approx. 10^-308 to 10^+308 (10^-324 for denormalized)  Special Values:  Zero - There are two zeros, positive and negative.  Infinity - exponent of all 1's and and a fraction of 0.  NAN (Not a number, produced by dividing 0 by 0 or infinity by infinity) - exponent of all 1's and any non-zero fraction.

Conversion Examples

Converting from decimal to IEEE floating point: Convert 9 to floating point single precision:

9 = 1.125 X 2^

1.125 base 10 = 1.001 base 2 Therefore, Sign = 0 (positive) Exponent = 3 + 127 or 130 or 1000 0010 binary Fraction = 1.001 or 001 with implicit "1." (Normalization) Complete number: 0 10000010 00100000000000000000000 S Exp Fraction Regroup by 4: 0100 0001 0001 0000 0000 0000 0000 0000 = 41100000H Converting from IEEE floating point to decimal: Convert 42E48000H (single precision floating point) to decimal: 42E48000H = 0100 0010 1110 0100 1000 0000 0000 0000 (Single precision =>32 bits => H is ignored) Regroup as sign, exponent and fraction: 0 10000101 11001001000000000000000 S Exp Fraction Therefore, Sign = 0 or positive Exponent = 128 + 4 + 1 = 133 reduced by 127 = 6 Fraction = 1.11001001 base 2 with implicity 1. Added (Normalization) Number = 1.11001001 X 2^6 or 1110010.01 base 2 (Left shift by 6) = 64 + 32 + 16 + 2 +. = 114.25 base 10