background image

Vol. 1 8-13

PROGRAMMING WITH THE X87 FPU

8.2 

X87 FPU DATA TYPES

The x87 FPU recognizes and operates on the following seven data types (see Figures 8-13): single-precision 
floating point, double-precision floating point, double extended-precision floating point, signed word integer, 
signed doubleword integer, signed quadword integer, and packed BCD decimal integers. 
For detailed information about these data types, see Section 4.2.2, “Floating-Point Data Types,” Section 4.2.1.2, 
“Signed Integers,”
 and Section 4.7, “BCD and Packed BCD Integers.”
With the exception of the 80-bit double extended-precision floating-point format, all of these data types exist in 
memory only. When they are loaded into x87 FPU data registers, they are converted into double extended-preci-
sion floating-point format and operated on in that format.
Denormal values are also supported in each of the floating-point types, as required by IEEE Standard 754. When a 
denormal number in single-precision or double-precision floating-point format is used as a source operand and the 
denormal exception is masked, the x87 FPU automatically normalizes the number when it is converted to double 
extended-precision format.
When stored in memory, the least significant byte of an x87 FPU data-type value is stored at the initial address 
specified for the value. Successive bytes from the value are then stored in successively higher addresses in 
memory. The floating-point instructions load and store memory operands using only the initial address of the 
operand. 

As a general rule, values should be stored in memory in double-precision format. This format provides sufficient 
range and precision to return correct results with a minimum of programmer attention. The single-precision format 
is useful for debugging algorithms, because rounding problems will manifest themselves more quickly in this 
format. The double extended-precision format is normally reserved for holding intermediate results in the x87 FPU 
registers and constants. Its extra length is designed to shield final results from the effects of rounding and over-
flow/underflow in intermediate calculations. However, when an application requires the maximum range and preci-
sion of the x87 FPU (for data storage, computations, and results), values can be stored in memory in double 
extended-precision format.

Figure 8-13.  x87 FPU Data Type Formats

0

Packed BCD Integers

79

D0

0

Quadword Integer

63

4 Bits = 1 BCD Digit

0

Doubleword Integer

31

0

Word Integer

15

Sign

D1

D2

D3

D4

D5

D6

D7

D8

D9

D10

D11

D12

D13

D14

D15

D16

D17

78

72 71

X

62

14

30

0

Double Extended-Precision Floating-Point

79

Sign

78

6463

0

Double-Precision Floating-Point

63 62

0

Single-Precision Floating-Point

3130

23 22

Fraction

Exp.

Sign

Implied Integer

Implied Integer

Sign

Exponent

Fraction

52 51

Fraction

Exponent

62

Integer

Sign

Sign

Sign