]>
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 | .\" |
48b6f086 | 12 | .TH FMA 3 2013-09-17 "" "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 |
c13182ef | 46 | The |
63aa9df0 | 47 | .BR fma () |
fea681da MK |
48 | function computes |
49 | .IR x " * " y " + " z . | |
6bd01965 | 50 | The result is rounded as one ternary operation according to the |
00b5d372 MK |
51 | current rounding mode (see |
52 | .BR fenv (3)). | |
6bd01965 MK |
53 | .SH RETURN VALUE |
54 | These functions return the value of | |
55 | .IR x " * " y " + " z , | |
56 | rounded as one ternary operation. | |
57 | ||
58 | If | |
59 | .I x | |
60 | or | |
61 | .I y | |
62 | is a NaN, a NaN is returned. | |
63 | ||
64 | If | |
65 | .I x | |
66 | times | |
67 | .I y | |
68 | is an exact infinity, and | |
69 | .I z | |
70 | is an infinity with the opposite sign, | |
efe294cb | 71 | a domain error occurs, |
6bd01965 MK |
72 | and a NaN is returned. |
73 | ||
c42ad30f MK |
74 | .\" POSIX.1-2008 allows some possible differences for the following two |
75 | .\" domain error cases, but on Linux they are treated the same (AFAICS). | |
76 | .\" Nevertheless, we'll mirror POSIX.1 and describe the two cases | |
77 | .\" separately. | |
6bd01965 MK |
78 | If one of |
79 | .I x | |
80 | or | |
81 | .I y | |
82 | is an infinity, the other is 0, and | |
83 | .I z | |
84 | is not a NaN, | |
efe294cb | 85 | a domain error occurs, and |
6bd01965 | 86 | a NaN is returned. |
c42ad30f MK |
87 | .\" POSIX.1 says that a NaN or an implementation-defined value shall |
88 | .\" be returned for this case. | |
6bd01965 MK |
89 | |
90 | If one of | |
91 | .I x | |
92 | or | |
93 | .I y | |
94 | is an infinity, and the other is 0, and | |
95 | .I z | |
96 | is a NaN, | |
97 | .\" POSIX.1 makes the domain error optional for this case. | |
efe294cb | 98 | a domain error occurs, and |
6bd01965 MK |
99 | a NaN is returned. |
100 | ||
101 | If | |
102 | .I x | |
103 | times | |
104 | .I y | |
385cf745 | 105 | is not an infinity times zero (or vice versa), and |
6bd01965 MK |
106 | .I z |
107 | is a NaN, | |
108 | a NaN is returned. | |
109 | ||
110 | If the result overflows, | |
efe294cb | 111 | a range error occurs, and |
6bd01965 MK |
112 | an infinity with the correct sign is returned. |
113 | ||
114 | If the result underflows, | |
efe294cb | 115 | a range error occurs, and |
6bd01965 MK |
116 | a signed 0 is returned. |
117 | .SH ERRORS | |
118 | See | |
119 | .BR math_error (7) | |
120 | for information on how to determine whether an error has occurred | |
121 | when calling these functions. | |
122 | .PP | |
123 | The following errors can occur: | |
124 | .TP | |
125 | Domain error: \fIx\fP * \fIy\fP + \fIz\fP, \ | |
126 | or \fIx\fP * \fIy\fP is invalid and \fIz\fP is not a NaN | |
127 | .\" .I errno | |
128 | .\" is set to | |
129 | .\" .BR EDOM . | |
130 | An invalid floating-point exception | |
131 | .RB ( FE_INVALID ) | |
132 | is raised. | |
133 | .TP | |
134 | Range error: result overflow | |
135 | .\" .I errno | |
136 | .\" is set to | |
137 | .\" .BR ERANGE . | |
138 | An overflow floating-point exception | |
139 | .RB ( FE_OVERFLOW ) | |
140 | is raised. | |
141 | .TP | |
142 | Range error: result underflow | |
143 | .\" .I errno | |
144 | .\" is set to | |
145 | .\" .BR ERANGE . | |
146 | An underflow floating-point exception | |
147 | .RB ( FE_UNDERFLOW ) | |
148 | is raised. | |
149 | .PP | |
150 | These functions do not set | |
151 | .IR errno . | |
152 | .\" FIXME . Is it intentional that these functions do not set errno? | |
153 | .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6801 | |
f0d7ce1d MK |
154 | .SH VERSIONS |
155 | These functions first appeared in glibc in version 2.1. | |
cc610618 PH |
156 | .SH ATTRIBUTES |
157 | .SS Multithreading (see pthreads(7)) | |
158 | The | |
159 | .BR fma (), | |
160 | .BR fmaf (), | |
161 | and | |
162 | .BR fmal () | |
163 | functions are thread-safe. | |
47297adb | 164 | .SH CONFORMING TO |
6bd01965 | 165 | C99, POSIX.1-2001. |
47297adb | 166 | .SH SEE ALSO |
fea681da MK |
167 | .BR remainder (3), |
168 | .BR remquo (3) |