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