1FMA(3) Linux Programmer's Manual FMA(3)
2
3
4
6 fma, fmaf, fmal - floating-point multiply and add
7
9 #include <math.h>
10
11 double fma(double x, double y, double z);
12 float fmaf(float x, float y, float z);
13 long double fmal(long double x, long double y, long double z);
14
15 Link with -lm.
16
17 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
18
19 fma(), fmaf(), fmal():
20 _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE ||
21 _POSIX_C_SOURCE >= 200112L;
22 or cc -std=c99
23
25 The fma() function computes x * y + z. The result is rounded as one
26 ternary operation according to the current rounding mode (see fenv(3)).
27
29 These functions return the value of x * y + z, rounded as one ternary
30 operation.
31
32 If x or y is a NaN, a NaN is returned.
33
34 If x times y is an exact infinity, and z is an infinity with the oppo‐
35 site sign, a domain error occurs, and a NaN is returned.
36
37 If one of x or y is an infinity, the other is 0, and z is not a NaN, a
38 domain error occurs, and a NaN is returned.
39
40 If one of x or y is an infinity, and the other is 0, and z is a NaN, a
41 domain error occurs, and a NaN is returned.
42
43 If x times y is not an infinity times zero (or vice versa), and z is a
44 NaN, a NaN is returned.
45
46 If the result overflows, a range error occurs, and an infinity with the
47 correct sign is returned.
48
49 If the result underflows, a range error occurs, and a signed 0 is
50 returned.
51
53 See math_error(7) for information on how to determine whether an error
54 has occurred when calling these functions.
55
56 The following errors can occur:
57
58 Domain error: x * y + z, or x * y is invalid and z is not a NaN
59 An invalid floating-point exception (FE_INVALID) is raised.
60
61 Range error: result overflow
62 An overflow floating-point exception (FE_OVERFLOW) is raised.
63
64 Range error: result underflow
65 An underflow floating-point exception (FE_UNDERFLOW) is raised.
66
67 These functions do not set errno.
68
70 These functions first appeared in glibc in version 2.1.
71
73 C99, POSIX.1-2001.
74
76 remainder(3), remquo(3)
77
79 This page is part of release 3.53 of the Linux man-pages project. A
80 description of the project, and information about reporting bugs, can
81 be found at http://www.kernel.org/doc/man-pages/.
82
83
84
85 2010-09-20 FMA(3)