]>
Commit | Line | Data |
---|---|---|
fea681da | 1 | .\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de) |
6bd01965 MK |
2 | .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk |
3 | .\" <mtk.manpages@gmail.com> | |
2297bf0e | 4 | .\" |
95fb8859 | 5 | .\" SPDX-License-Identifier: GPL-1.0-or-later |
0389adc9 | 6 | .\" |
4022b76e MK |
7 | .\" Modified 2004-11-15, Added further text on FLT_ROUNDS |
8 | .\" as suggested by AEB and Fabian Kreutz | |
fea681da | 9 | .\" |
1ae6b2c7 | 10 | .TH FMA 3 2021-03-22 GNU "Linux Programmer's Manual" |
fea681da MK |
11 | .SH NAME |
12 | fma, fmaf, fmal \- floating-point multiply and add | |
2af19291 AC |
13 | .SH LIBRARY |
14 | Math library | |
8fc3b2cf | 15 | .RI ( libm ", " \-lm ) |
fea681da MK |
16 | .SH SYNOPSIS |
17 | .nf | |
18 | .B #include <math.h> | |
68e4db0a | 19 | .PP |
fea681da | 20 | .BI "double fma(double " x ", double " y ", double " z ); |
fea681da | 21 | .BI "float fmaf(float " x ", float " y ", float " z ); |
fea681da MK |
22 | .BI "long double fmal(long double " x ", long double " y ", long double " z ); |
23 | .fi | |
68e4db0a | 24 | .PP |
d39ad78f | 25 | .RS -4 |
6bd01965 MK |
26 | Feature Test Macro Requirements for glibc (see |
27 | .BR feature_test_macros (7)): | |
d39ad78f | 28 | .RE |
68e4db0a | 29 | .PP |
6bd01965 MK |
30 | .BR fma (), |
31 | .BR fmaf (), | |
32 | .BR fmal (): | |
9d2adbae | 33 | .nf |
5c10d2c5 | 34 | _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
9d2adbae | 35 | .fi |
fea681da | 36 | .SH DESCRIPTION |
5600f73a | 37 | These functions compute |
fea681da | 38 | .IR x " * " y " + " z . |
6bd01965 | 39 | The result is rounded as one ternary operation according to the |
00b5d372 MK |
40 | current rounding mode (see |
41 | .BR fenv (3)). | |
6bd01965 MK |
42 | .SH RETURN VALUE |
43 | These functions return the value of | |
44 | .IR x " * " y " + " z , | |
45 | rounded as one ternary operation. | |
847e0d88 | 46 | .PP |
6bd01965 MK |
47 | If |
48 | .I x | |
49 | or | |
50 | .I y | |
51 | is a NaN, a NaN is returned. | |
847e0d88 | 52 | .PP |
6bd01965 MK |
53 | If |
54 | .I x | |
55 | times | |
56 | .I y | |
57 | is an exact infinity, and | |
58 | .I z | |
59 | is an infinity with the opposite sign, | |
efe294cb | 60 | a domain error occurs, |
6bd01965 | 61 | and a NaN is returned. |
847e0d88 | 62 | .PP |
c42ad30f MK |
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 | |
66 | .\" separately. | |
6bd01965 MK |
67 | If one of |
68 | .I x | |
69 | or | |
70 | .I y | |
71 | is an infinity, the other is 0, and | |
72 | .I z | |
73 | is not a NaN, | |
efe294cb | 74 | a domain error occurs, and |
6bd01965 | 75 | a NaN is returned. |
c42ad30f MK |
76 | .\" POSIX.1 says that a NaN or an implementation-defined value shall |
77 | .\" be returned for this case. | |
847e0d88 | 78 | .PP |
6bd01965 MK |
79 | If one of |
80 | .I x | |
81 | or | |
82 | .I y | |
83 | is an infinity, and the other is 0, and | |
84 | .I z | |
85 | is a NaN, | |
86 | .\" POSIX.1 makes the domain error optional for this case. | |
efe294cb | 87 | a domain error occurs, and |
6bd01965 | 88 | a NaN is returned. |
847e0d88 | 89 | .PP |
6bd01965 MK |
90 | If |
91 | .I x | |
92 | times | |
93 | .I y | |
385cf745 | 94 | is not an infinity times zero (or vice versa), and |
6bd01965 MK |
95 | .I z |
96 | is a NaN, | |
97 | a NaN is returned. | |
847e0d88 | 98 | .PP |
6bd01965 | 99 | If the result overflows, |
efe294cb | 100 | a range error occurs, and |
6bd01965 | 101 | an infinity with the correct sign is returned. |
847e0d88 | 102 | .PP |
6bd01965 | 103 | If the result underflows, |
efe294cb | 104 | a range error occurs, and |
6bd01965 MK |
105 | a signed 0 is returned. |
106 | .SH ERRORS | |
107 | See | |
108 | .BR math_error (7) | |
109 | for information on how to determine whether an error has occurred | |
110 | when calling these functions. | |
111 | .PP | |
112 | The following errors can occur: | |
113 | .TP | |
114 | Domain error: \fIx\fP * \fIy\fP + \fIz\fP, \ | |
115 | or \fIx\fP * \fIy\fP is invalid and \fIz\fP is not a NaN | |
116 | .\" .I errno | |
117 | .\" is set to | |
118 | .\" .BR EDOM . | |
119 | An invalid floating-point exception | |
120 | .RB ( FE_INVALID ) | |
121 | is raised. | |
122 | .TP | |
123 | Range error: result overflow | |
124 | .\" .I errno | |
125 | .\" is set to | |
126 | .\" .BR ERANGE . | |
127 | An overflow floating-point exception | |
128 | .RB ( FE_OVERFLOW ) | |
129 | is raised. | |
130 | .TP | |
131 | Range error: result underflow | |
132 | .\" .I errno | |
133 | .\" is set to | |
134 | .\" .BR ERANGE . | |
135 | An underflow floating-point exception | |
136 | .RB ( FE_UNDERFLOW ) | |
137 | is raised. | |
138 | .PP | |
139 | These functions do not set | |
140 | .IR errno . | |
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 | |
f0d7ce1d MK |
143 | .SH VERSIONS |
144 | These functions first appeared in glibc in version 2.1. | |
cc610618 | 145 | .SH ATTRIBUTES |
d2d44c15 MK |
146 | For an explanation of the terms used in this section, see |
147 | .BR attributes (7). | |
c466875e MK |
148 | .ad l |
149 | .nh | |
d2d44c15 MK |
150 | .TS |
151 | allbox; | |
c466875e | 152 | lbx lb lb |
d2d44c15 MK |
153 | l l l. |
154 | Interface Attribute Value | |
155 | T{ | |
cc610618 PH |
156 | .BR fma (), |
157 | .BR fmaf (), | |
cc610618 | 158 | .BR fmal () |
d2d44c15 MK |
159 | T} Thread safety MT-Safe |
160 | .TE | |
c466875e MK |
161 | .hy |
162 | .ad | |
163 | .sp 1 | |
47297adb | 164 | .SH CONFORMING TO |
9a74e018 | 165 | C99, POSIX.1-2001, POSIX.1-2008. |
47297adb | 166 | .SH SEE ALSO |
fea681da MK |
167 | .BR remainder (3), |
168 | .BR remquo (3) |