Docsity

Floating Point Numbers: Representation and Range in IEEE Single and Double Precision - Pro, Study notes of Algebra

Toggle sidebar
bg1
Floating Point Numbers
Jiangguo (James) Liu โˆ—
January 25, 2006
1 Representations of Real Numbers
Real numbers are represented as floating point numbers inside computers. A floating
point number can be written in binary form as
x= (โˆ’1)s2E(b0.b1b2. . . bpโˆ’1).
Bit strings are utilized to represent the sign s, the exponent E, and the mantissa
b1. . . bpโˆ’1, whereas b0is usually implicit. IEEE arithmetic includes two kinds of
floating point numbers: single precision (32 bits long) and double precision (64
bits long).
1.1 Single Precision
The bit structure for a 32-bit IEEE single precision is shown below.
s e f
1 8 23
sign exponent mantissa
Among these 32 bits, 1 bit is assigned to the sign s, 8 bits are assigned to the
exponent e, and the remaining 23 bits (b1. . . b23) to the mantissa f. The value of b0
is implicit.
Five combinations of s, e, f are utilized to represent five different types of infor-
mation.
โ€ขCase 1โ‰คeโ‰ค254.
Anormalized floating point number is stored and its value is
x= (โˆ’1)s(1.f)22eโˆ’127.
In this situation, b0is implicitly 1 and fmay or may not be 0.
โˆ—Department of Mathematics Colorado State University Fort Collins, CO 80523-1874
1
pf2

Partial preview of the text

Download Floating Point Numbers: Representation and Range in IEEE Single and Double Precision - Pro and more Study notes Algebra in PDF only on Docsity!

Floating Point Numbers

Jiangguo (James) Liu โˆ—

January 25, 2006

1 Representations of Real Numbers

Real numbers are represented as floating point numbers inside computers. A floating point number can be written in binary form as

x = (โˆ’1)s 2 E^ (b 0 .b 1 b 2... bpโˆ’ 1 ).

Bit strings are utilized to represent the sign s, the exponent E, and the mantissa b 1... bpโˆ’ 1 , whereas b 0 is usually implicit. IEEE arithmetic includes two kinds of floating point numbers: single precision (32 bits long) and double precision ( bits long).

1.1 Single Precision

The bit structure for a 32-bit IEEE single precision is shown below.

s e (^) f 1 8 23 sign exponent mantissa

Among these 32 bits, 1 bit is assigned to the sign s, 8 bits are assigned to the exponent e, and the remaining 23 bits (b 1... b 23 ) to the mantissa f. The value of b 0 is implicit.

Five combinations of s, e, f are utilized to represent five different types of infor- mation.

  • Case 1 โ‰ค e โ‰ค 254. A normalized floating point number is stored and its value is

x = (โˆ’1)s^ (1.f ) 2 2 eโˆ’^127.

In this situation, b 0 is implicitly 1 and f may or may not be 0. โˆ—Department of Mathematics Colorado State University Fort Collins, CO 80523-

([email protected])

  • Case e = 0 and f = 0. Zeros are stored: x = (โˆ’1)s0. We have a positive zero and a negative zero.
  • Case e = 0 and f 6 = 0. A denormalized number is stored (details omitted).
  • Case e = 255 and f = 0. Then a signed infinity is stored: x = (โˆ’1)sโˆž. A signed infinity is produced if the absolute value of a floating point number is too big.
  • Case e = 255 and f 6 = 0. Then we have a NaN (Not a Number). A NaN is the result of an invalid floating point operation like 0/0 and 0 ร— โˆž. Once produced, NaNs propagate throughout a computation and may appear in your incorrect final results.

Clearly, the smallest floating point number (in terms of absolute value) is

(1.0000 0000 0000 0000 0000 000) 2 2 โˆ’^126 โ‰ˆ 1. 1755 ร— 10 โˆ’^38.

The largest floating point number is

(1.1111 1111 1111 1111 1111 111) 2 2127 = (2 โˆ’ 2 โˆ’^23 ) ร— 2127 โ‰ˆ 3. 4028 ร— 1038.

In addition, the smallest unit in the 23-bit mantissa is 2โˆ’^23 โ‰ˆ 1. 1921 ร— 10 โˆ’^7. So we have only 6 accurate figures in the decimal representation. These may not be enough for some scientific computing, and hence double precision is needed.

1.2 Double Precision

Among the 64 bits for a double precision floating number, again, only 1 bit is needed for the sign s. Now 11 bits are used for the exponent e, and the remaining 52 bits are assigned to the mantissa f. As we expected, the exponent 00000000000 and 11111111111 are reserved. Also, the exponent inside the computer is a biased exponent. We have (00000000001) 2 corresponding to (โˆ’1022) 10 and (11111111110) 2 corresponding to (1023) 10.

Single precision has only 6 accurate decimal figures whereas double precision has 15 accurate decimal figures.

On a 32-bit computer, one word is 4 bytes, i.e., 32-bits. So all operations on single precision floating numbers can be implemented by the hardware. On the contrary, double precision floating arithmetics have to be implemented through softwares and hence much slower.