A bit-by-bit account of floating-point values

The last several sections have focused on floating-point values. This section concerns itself with the representation of numbers as bit strings. Figure 55 shows how a floating-point number is represented in memory:


The exponent e ranges between 0 and , where n is the number of bits in the exponent field. It has a bias of ; the mathematical exponent is . Several cases arise:

The situation is different for a
long double value on a PowerPC platform. Figure 55 shows how such a value is stored as a pair of double numbers. Its value is the mathematical sum . Each half of the value is a double number encoded as in Figure 55.


The magnitude of is at most half a unit in the last place of . The signs of the two values can differ.

Byte order of data

Although these figures describe floating-point values as strings of bits, they do not say how these bits are arranged in memory. Two conventions are in widespread use, and their differences can undermine an application's portability in the absence of tools to insulate the application from the underlying machine architecture. Figure 55 illustrates a double value x as a sequence of 8 bytes.


Byte order determines which byte is at the lowest memory address, the next lowest, and so on. Only two conventions are in common use. On big endian platforms, byte 0--the byte with the most significant bits of the value--is at the lowest memory address, byte 1 is at the next lowest, and so on until byte 7, which resides at the highest address. Little endian platforms are just the opposite: byte 7 is at the lowest address and byte 0 is at the highest.

X86 is a little endian architecture. Both PowerPC and PA-RISC, typical of new architectures, have a control register that is set (typically at startup and then never changed) to indicate either big or little endian addressing. "Byte order" on page 252 discusses the effect of byte order on portability.

Details of floating-point formats

Table 5 gives the relevant parameters of the floating-point types.

Number system
Platform

Width

Range of e

Bias
Width
of e
Implicit 1 bit? Width
of f

Details of floating-point storage formats
Illustrative
6-bit numbers
None to Y
float All to Y
double All to Y
long double X86 to N
long double PA-RISC to Y
long double PowerPC to Y

Formats with an implicit leading bit

All formats--except long double on X86 platforms--have an implicit leading significant bit. They share other properties as well. The biased exponent ranges from 0 to , where k is the width of the exponent field in bits. The biased exponent 0 is used to encode the value zero and subnormal numbers; in this case the implicit bit is defined to be 0, not 1, and the exponent is that of the smallest normal number. The biased exponent is used to encode signed infinity (when f is zero) and NaNs.

The lone explicit leading 1 bit

Only the long double type on X86 platforms has an explicit leading bit in the significand. Its fraction f is 63 bits wide, for a total significand width of 64 bits. On that platform, the leading bit must be 0 for numbers with the smallest exponent and must be 1 for numbers with larger exponents.

NOTE On X86 platforms, values with the smallest exponent and a leading bit of 1 or larger exponents and leading bit of 0 lie outside the CommonPoint computational model. See Chapter 13 for details.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker