AMD amd64 architecture User Manual
270
x87 Floating-Point Programming
AMD64 Technology
24592—Rev. 3.15—November 2009
condition-code bit in the x87 status word is set to 1, and the argument is returned as the result. If
software detects an out-of-range argument, the FPREM or FPREM1 instruction can be used to reduce
the magnitude of the argument before using the FSIN, FCOS, FSINCOS, or FPTAN instruction again.
software detects an out-of-range argument, the FPREM or FPREM1 instruction can be used to reduce
the magnitude of the argument before using the FSIN, FCOS, FSINCOS, or FPTAN instruction again.
Logarithmic Functions
•
F2XM1—Floating-Point Compute 2
x
–1
•
FSCALE—Floating-Point Scale
•
FYL2X—Floating-Point y * log2x
•
FYL2XP1—Floating-Point y * log2(x +1)
The F2XM1 instruction computes Y = 2
X
– 1. X is located in ST(0) and must fall between –1 and +1.
Y replaces X in ST(0). If ST(0) is out of range, the instruction returns an undefined result but no x87
status-word exception bits are affected.
status-word exception bits are affected.
The FSCALE instruction replaces ST(0) with ST(0) times 2
n
, where n is the value in ST(1) truncated
to an integer. This provides a fast method of multiplying by integral powers of 2.
The FYL2X instruction computes Z = Y * log
2
X. X is located in ST(0) and Y is located in ST(1). X
must be greater than 0. The result, Z, replaces Y in ST(1), which becomes the new top-of-stack
because X is popped off the stack.
because X is popped off the stack.
The FYL2XP1 instruction computes Z = Y * log
2
(X + 1). X located in ST(0) and must be in the range
0 < |X| < (1 – 2
½
/ 2). Y is taken from ST(1). The result, Z, replaces Y in ST(1), which becomes the new
top-of-stack because X is popped off the stack.
Accuracy of Transcendental Results.
x87 computations are carried out in double-extended-
precision format, so that the transcendental functions provide results accurate to within one unit in the
last place (ulp) for each of the floating-point data types.
last place (ulp) for each of the floating-point data types.
Argument Reduction Using Pi.
The FPREM and FPREM1 instructions can be used to reduce an
argument of a trigonometric function by a multiple of Pi. The following example shows a reduction by
2
2
π:
sin(n*2
π + x) = sin(x) for all integral n
In this example, the range is 0
≤ x < 2π in the case of FPREM or -π ≤ x ≤ π in the case of FPREM1.
Negative arguments are reduced by repeatedly subtracting –2
for details of the instructions.
6.4.6 Compare and Test
The compare-and-test instructions set and clear flags in the rFLAGS register to indicate the
relationship between two operands (less, equal, greater, or unordered).
relationship between two operands (less, equal, greater, or unordered).
Floating-Point Ordered Compare
•
FCOM—Floating-Point Compare