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 .\" SPDX-License-Identifier: GPL-1.0-or-later
7 .\" Modified 2004-11-15, Added further text on FLT_ROUNDS
8 .\" as suggested by AEB and Fabian Kreutz
10 .TH FMA 3 2021-03-22 "" "Linux Programmer's Manual"
12 fma, fmaf, fmal \- floating-point multiply and add
15 .RI ( libm ", " \-lm )
20 .BI "double fma(double " x ", double " y ", double " z );
21 .BI "float fmaf(float " x ", float " y ", float " z );
22 .BI "long double fmal(long double " x ", long double " y ", long double " z );
26 Feature Test Macro Requirements for glibc (see
27 .BR feature_test_macros (7)):
34 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
37 These functions compute
38 .IR x " * " y " + " z .
39 The result is rounded as one ternary operation according to the
40 current rounding mode (see
43 These functions return the value of
44 .IR x " * " y " + " z ,
45 rounded as one ternary operation.
51 is a NaN, a NaN is returned.
57 is an exact infinity, and
59 is an infinity with the opposite sign,
60 a domain error occurs,
61 and a NaN is returned.
63 .\" POSIX.1-2008 allows some possible differences for the following two
64 .\" domain error cases, but on Linux they are treated the same (AFAICS).
65 .\" Nevertheless, we'll mirror POSIX.1 and describe the two cases
71 is an infinity, the other is 0, and
74 a domain error occurs, and
76 .\" POSIX.1 says that a NaN or an implementation-defined value shall
77 .\" be returned for this case.
83 is an infinity, and the other is 0, and
86 .\" POSIX.1 makes the domain error optional for this case.
87 a domain error occurs, and
94 is not an infinity times zero (or vice versa), and
99 If the result overflows,
100 a range error occurs, and
101 an infinity with the correct sign is returned.
103 If the result underflows,
104 a range error occurs, and
105 a signed 0 is returned.
109 for information on how to determine whether an error has occurred
110 when calling these functions.
112 The following errors can occur:
114 Domain error: \fIx\fP * \fIy\fP + \fIz\fP, \
115 or \fIx\fP * \fIy\fP is invalid and \fIz\fP is not a NaN
119 An invalid floating-point exception
123 Range error: result overflow
127 An overflow floating-point exception
131 Range error: result underflow
135 An underflow floating-point exception
139 These functions do not set
141 .\" FIXME . Is it intentional that these functions do not set errno?
142 .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6801
144 These functions first appeared in glibc in version 2.1.
146 For an explanation of the terms used in this section, see
154 Interface Attribute Value
159 T} Thread safety MT-Safe
165 C99, POSIX.1-2001, POSIX.1-2008.