Sei sulla pagina 1di 3

Real Numbers

No computer number system can represent all real numbers. Various systems can be used for a subset of real numbers. Number System Fixed-point Rational Floating-point Format i.f p/q mbe Characteristics Low-precision Difficult to work with Most common way to handle reals

Fixed Point Numbers


In the decimal system, a decimal point (radix point) separates the whole numbers from the fractional part. Examples: 37.25 ( integer = 37, fraction = 25/100) 123.567 10.12345678 The binary equivalent of a fixed point number can be determined by computing the binary representation for each part separately. 1) For the integer part: Use subtraction or division method previously learned. 2) For the fractional part: Use the subtraction or multiplication method. For example, 37.25 can be analyzed as: 101 100 10-1 10-2 Tens Units Tenths Hundredths 3 7 2 5 37.25 = (3 10) + (7 1) + (2 1/10) + (5 1/100) Other Examples: 60.7510 190.562510 = = 111100.112 10111110.10012

We dont store the radix point so just make sure the radix point is always in the same position.

Floating-Point Numbers
If X is a real number, then its normal form representation is:

Where m = mantissa and e = exponent

Figure 1: Parts of a floating-point number: Normalization Every binary number, except for the representation for the number zero, can be normalized so that the radix point falls to the right of the leftmost 1 bit. 37.2510 = 100101.012 = 1.0010101 x 25 7.62510 = 111.1012 = 1.11101 x 22 0.312510 = 0.01012 = 1.01 x 2-2 The radix point floats the correct position, thats why its called the floating point number. Because the leftmost digit is always 1, we dont need to store this bit.

IEEE 754 Floating Point Standard


The IEEE754 standard was originally established in 1985, and last revised in 2008. It defines formats for zero, finite numbers, special codes for infinities (+ and ), and undefined or unrepresentable values. Five basic number formats are available, but the most commonly used are 32-bit single precision and 64-bit double precision. We will cover only the 32-bit single precision format.

The sign field The value is 0 for positive numbers (-1)0 = +1, and 1 for negative numbers (-1)1 = -1. The exponent field An unsigned 8-bit number, relative to a bias of 127. Example: exponent 5 is stored as (127+5=132) or 10000100 Example: exponent -4 is stored as (127+(-4)=123) or 01111011

The mantissa field A set of 0s and 1s to the right of the normalized binary number. Example: for the binary number 1.00101 23, the mantissa is 00101 The mantissa is stored in a 23 bit field, so we pad zeros to the right: o 00101000000000000000000

Other IEEE 754 Examples 0 1000 0011 0000 0000 0000 0000 0000 000 = 1 24 = 16 0 0011 0001 0000 0000 0000 0000 0000 000 = 1 2-78 = 3.3087e-24 0 1000 0001 0100 0000 0000 0000 0000 000 = 1.25 22 = 5

Potrebbero piacerti anche