1 .\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
2 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3 .\" <mtk.manpages@gmail.com>
5 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
6 .\" Distributed under GPL
9 .\" Modified 2004-11-15, Added further text on FLT_ROUNDS
10 .\" as suggested by AEB and Fabian Kreutz
12 .TH FMA 3 2017-09-15 "" "Linux Programmer's Manual"
14 fma, fmaf, fmal \- floating-point multiply and add
19 .BI "double fma(double " x ", double " y ", double " z );
20 .BI "float fmaf(float " x ", float " y ", float " z );
21 .BI "long double fmal(long double " x ", long double " y ", long double " z );
27 Feature Test Macro Requirements for glibc (see
28 .BR feature_test_macros (7)):
36 _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
40 These functions compute
41 .IR x " * " y " + " z .
42 The result is rounded as one ternary operation according to the
43 current rounding mode (see
46 These functions return the value of
47 .IR x " * " y " + " z ,
48 rounded as one ternary operation.
54 is a NaN, a NaN is returned.
60 is an exact infinity, and
62 is an infinity with the opposite sign,
63 a domain error occurs,
64 and a NaN is returned.
66 .\" POSIX.1-2008 allows some possible differences for the following two
67 .\" domain error cases, but on Linux they are treated the same (AFAICS).
68 .\" Nevertheless, we'll mirror POSIX.1 and describe the two cases
74 is an infinity, the other is 0, and
77 a domain error occurs, and
79 .\" POSIX.1 says that a NaN or an implementation-defined value shall
80 .\" be returned for this case.
86 is an infinity, and the other is 0, and
89 .\" POSIX.1 makes the domain error optional for this case.
90 a domain error occurs, and
97 is not an infinity times zero (or vice versa), and
102 If the result overflows,
103 a range error occurs, and
104 an infinity with the correct sign is returned.
106 If the result underflows,
107 a range error occurs, and
108 a signed 0 is returned.
112 for information on how to determine whether an error has occurred
113 when calling these functions.
115 The following errors can occur:
117 Domain error: \fIx\fP * \fIy\fP + \fIz\fP, \
118 or \fIx\fP * \fIy\fP is invalid and \fIz\fP is not a NaN
122 An invalid floating-point exception
126 Range error: result overflow
130 An overflow floating-point exception
134 Range error: result underflow
138 An underflow floating-point exception
142 These functions do not set
144 .\" FIXME . Is it intentional that these functions do not set errno?
145 .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6801
147 These functions first appeared in glibc in version 2.1.
149 For an explanation of the terms used in this section, see
155 Interface Attribute Value
160 T} Thread safety MT-Safe
163 C99, POSIX.1-2001, POSIX.1-2008.