]>
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 | .\" |
38f20bb9 MK |
5 | .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE) |
6 | .\" Distributed under GPL | |
7 | .\" %%%LICENSE_END | |
0389adc9 | 8 | .\" |
4022b76e MK |
9 | .\" Modified 2004-11-15, Added further text on FLT_ROUNDS |
10 | .\" as suggested by AEB and Fabian Kreutz | |
fea681da | 11 | .\" |
c73595c2 | 12 | .TH FMA 3 2015-04-19 "" "Linux Programmer's Manual" |
fea681da MK |
13 | .SH NAME |
14 | fma, fmaf, fmal \- floating-point multiply and add | |
15 | .SH SYNOPSIS | |
16 | .nf | |
17 | .B #include <math.h> | |
18 | .sp | |
19 | .BI "double fma(double " x ", double " y ", double " z ); | |
d39541ec | 20 | .br |
fea681da | 21 | .BI "float fmaf(float " x ", float " y ", float " z ); |
d39541ec | 22 | .br |
fea681da MK |
23 | .BI "long double fmal(long double " x ", long double " y ", long double " z ); |
24 | .fi | |
25 | .sp | |
6bd01965 MK |
26 | Link with \fI\-lm\fP. |
27 | .sp | |
28 | .in -4n | |
29 | Feature Test Macro Requirements for glibc (see | |
30 | .BR feature_test_macros (7)): | |
31 | .in | |
32 | .sp | |
33 | .ad l | |
34 | .BR fma (), | |
35 | .BR fmaf (), | |
36 | .BR fmal (): | |
f1f0e4ed | 37 | .RS 4 |
a5ea8d23 MK |
38 | _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE || |
39 | _POSIX_C_SOURCE\ >=\ 200112L; | |
f1f0e4ed MK |
40 | .br |
41 | or | |
6bd01965 | 42 | .I cc\ -std=c99 |
f1f0e4ed MK |
43 | .RE |
44 | .ad | |
fea681da | 45 | .SH DESCRIPTION |
5600f73a | 46 | These functions compute |
fea681da | 47 | .IR x " * " y " + " z . |
6bd01965 | 48 | The result is rounded as one ternary operation according to the |
00b5d372 MK |
49 | current rounding mode (see |
50 | .BR fenv (3)). | |
6bd01965 MK |
51 | .SH RETURN VALUE |
52 | These functions return the value of | |
53 | .IR x " * " y " + " z , | |
54 | rounded as one ternary operation. | |
55 | ||
56 | If | |
57 | .I x | |
58 | or | |
59 | .I y | |
60 | is a NaN, a NaN is returned. | |
61 | ||
62 | If | |
63 | .I x | |
64 | times | |
65 | .I y | |
66 | is an exact infinity, and | |
67 | .I z | |
68 | is an infinity with the opposite sign, | |
efe294cb | 69 | a domain error occurs, |
6bd01965 MK |
70 | and a NaN is returned. |
71 | ||
c42ad30f MK |
72 | .\" POSIX.1-2008 allows some possible differences for the following two |
73 | .\" domain error cases, but on Linux they are treated the same (AFAICS). | |
74 | .\" Nevertheless, we'll mirror POSIX.1 and describe the two cases | |
75 | .\" separately. | |
6bd01965 MK |
76 | If one of |
77 | .I x | |
78 | or | |
79 | .I y | |
80 | is an infinity, the other is 0, and | |
81 | .I z | |
82 | is not a NaN, | |
efe294cb | 83 | a domain error occurs, and |
6bd01965 | 84 | a NaN is returned. |
c42ad30f MK |
85 | .\" POSIX.1 says that a NaN or an implementation-defined value shall |
86 | .\" be returned for this case. | |
6bd01965 MK |
87 | |
88 | If one of | |
89 | .I x | |
90 | or | |
91 | .I y | |
92 | is an infinity, and the other is 0, and | |
93 | .I z | |
94 | is a NaN, | |
95 | .\" POSIX.1 makes the domain error optional for this case. | |
efe294cb | 96 | a domain error occurs, and |
6bd01965 MK |
97 | a NaN is returned. |
98 | ||
99 | If | |
100 | .I x | |
101 | times | |
102 | .I y | |
385cf745 | 103 | is not an infinity times zero (or vice versa), and |
6bd01965 MK |
104 | .I z |
105 | is a NaN, | |
106 | a NaN is returned. | |
107 | ||
108 | If the result overflows, | |
efe294cb | 109 | a range error occurs, and |
6bd01965 MK |
110 | an infinity with the correct sign is returned. |
111 | ||
112 | If the result underflows, | |
efe294cb | 113 | a range error occurs, and |
6bd01965 MK |
114 | a signed 0 is returned. |
115 | .SH ERRORS | |
116 | See | |
117 | .BR math_error (7) | |
118 | for information on how to determine whether an error has occurred | |
119 | when calling these functions. | |
120 | .PP | |
121 | The following errors can occur: | |
122 | .TP | |
123 | Domain error: \fIx\fP * \fIy\fP + \fIz\fP, \ | |
124 | or \fIx\fP * \fIy\fP is invalid and \fIz\fP is not a NaN | |
125 | .\" .I errno | |
126 | .\" is set to | |
127 | .\" .BR EDOM . | |
128 | An invalid floating-point exception | |
129 | .RB ( FE_INVALID ) | |
130 | is raised. | |
131 | .TP | |
132 | Range error: result overflow | |
133 | .\" .I errno | |
134 | .\" is set to | |
135 | .\" .BR ERANGE . | |
136 | An overflow floating-point exception | |
137 | .RB ( FE_OVERFLOW ) | |
138 | is raised. | |
139 | .TP | |
140 | Range error: result underflow | |
141 | .\" .I errno | |
142 | .\" is set to | |
143 | .\" .BR ERANGE . | |
144 | An underflow floating-point exception | |
145 | .RB ( FE_UNDERFLOW ) | |
146 | is raised. | |
147 | .PP | |
148 | These functions do not set | |
149 | .IR errno . | |
150 | .\" FIXME . Is it intentional that these functions do not set errno? | |
151 | .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6801 | |
f0d7ce1d MK |
152 | .SH VERSIONS |
153 | These functions first appeared in glibc in version 2.1. | |
cc610618 | 154 | .SH ATTRIBUTES |
d2d44c15 MK |
155 | For an explanation of the terms used in this section, see |
156 | .BR attributes (7). | |
157 | .TS | |
158 | allbox; | |
159 | lbw21 lb lb | |
160 | l l l. | |
161 | Interface Attribute Value | |
162 | T{ | |
cc610618 PH |
163 | .BR fma (), |
164 | .BR fmaf (), | |
cc610618 | 165 | .BR fmal () |
d2d44c15 MK |
166 | T} Thread safety MT-Safe |
167 | .TE | |
47297adb | 168 | .SH CONFORMING TO |
9a74e018 | 169 | C99, POSIX.1-2001, POSIX.1-2008. |
47297adb | 170 | .SH SEE ALSO |
fea681da MK |
171 | .BR remainder (3), |
172 | .BR remquo (3) |