2 .\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
3 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
4 .\" <mtk.manpages@gmail.com>
6 .\" SPDX-License-Identifier: GPL-1.0-or-later
8 .\" Modified 2004-11-15, Added further text on FLT_ROUNDS
9 .\" as suggested by AEB and Fabian Kreutz
11 .TH fma 3 (date) "Linux man-pages (unreleased)"
13 fma, fmaf, fmal \- floating-point multiply and add
16 .RI ( libm ", " \-lm )
21 .BI "double fma(double " x ", double " y ", double " z );
22 .BI "float fmaf(float " x ", float " y ", float " z );
23 .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)):
35 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
38 These functions compute
39 .IR x " * " y " + " z .
40 The result is rounded as one ternary operation according to the
41 current rounding mode (see
44 These functions return the value of
45 .IR x " * " y " + " z ,
46 rounded as one ternary operation.
52 is a NaN, a NaN is returned.
58 is an exact infinity, and
60 is an infinity with the opposite sign,
61 a domain error occurs,
62 and a NaN is returned.
64 .\" POSIX.1-2008 allows some possible differences for the following two
65 .\" domain error cases, but on Linux they are treated the same (AFAICS).
66 .\" Nevertheless, we'll mirror POSIX.1 and describe the two cases
72 is an infinity, the other is 0, and
75 a domain error occurs, and
77 .\" POSIX.1 says that a NaN or an implementation-defined value shall
78 .\" be returned for this case.
84 is an infinity, and the other is 0, and
87 .\" POSIX.1 makes the domain error optional for this case.
88 a domain error occurs, and
95 is not an infinity times zero (or vice versa), and
100 If the result overflows,
101 a range error occurs, and
102 an infinity with the correct sign is returned.
104 If the result underflows,
105 a range error occurs, and
106 a signed 0 is returned.
110 for information on how to determine whether an error has occurred
111 when calling these functions.
113 The following errors can occur:
115 Domain error: \fIx\fP * \fIy\fP + \fIz\fP, \
116 or \fIx\fP * \fIy\fP is invalid and \fIz\fP is not a NaN
120 An invalid floating-point exception
124 Range error: result overflow
128 An overflow floating-point exception
132 Range error: result underflow
136 An underflow floating-point exception
140 These functions do not set
142 .\" FIXME . Is it intentional that these functions do not set errno?
143 .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6801
145 These functions were added in glibc 2.1.
147 For an explanation of the terms used in this section, see
155 Interface Attribute Value
160 T} Thread safety MT-Safe
166 C99, POSIX.1-2001, POSIX.1-2008.