]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/fma.3
floor.3: Reformat thread-safety information
[thirdparty/man-pages.git] / man3 / fma.3
CommitLineData
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
14fma, 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
26Link with \fI\-lm\fP.
27.sp
28.in -4n
29Feature 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
41or
6bd01965 42.I cc\ -std=c99
f1f0e4ed
MK
43.RE
44.ad
fea681da 45.SH DESCRIPTION
c13182ef 46The
63aa9df0 47.BR fma ()
fea681da
MK
48function computes
49.IR x " * " y " + " z .
6bd01965 50The result is rounded as one ternary operation according to the
00b5d372
MK
51current rounding mode (see
52.BR fenv (3)).
6bd01965
MK
53.SH RETURN VALUE
54These functions return the value of
55.IR x " * " y " + " z ,
56rounded as one ternary operation.
57
58If
59.I x
60or
61.I y
62is a NaN, a NaN is returned.
63
64If
65.I x
66times
67.I y
68is an exact infinity, and
69.I z
70is an infinity with the opposite sign,
efe294cb 71a domain error occurs,
6bd01965
MK
72and 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
78If one of
79.I x
80or
81.I y
82is an infinity, the other is 0, and
83.I z
84is not a NaN,
efe294cb 85a domain error occurs, and
6bd01965 86a 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
90If one of
91.I x
92or
93.I y
94is an infinity, and the other is 0, and
95.I z
96is a NaN,
97.\" POSIX.1 makes the domain error optional for this case.
efe294cb 98a domain error occurs, and
6bd01965
MK
99a NaN is returned.
100
101If
102.I x
103times
104.I y
385cf745 105is not an infinity times zero (or vice versa), and
6bd01965
MK
106.I z
107is a NaN,
108a NaN is returned.
109
110If the result overflows,
efe294cb 111a range error occurs, and
6bd01965
MK
112an infinity with the correct sign is returned.
113
114If the result underflows,
efe294cb 115a range error occurs, and
6bd01965
MK
116a signed 0 is returned.
117.SH ERRORS
118See
119.BR math_error (7)
120for information on how to determine whether an error has occurred
121when calling these functions.
122.PP
123The following errors can occur:
124.TP
125Domain error: \fIx\fP * \fIy\fP + \fIz\fP, \
126or \fIx\fP * \fIy\fP is invalid and \fIz\fP is not a NaN
127.\" .I errno
128.\" is set to
129.\" .BR EDOM .
130An invalid floating-point exception
131.RB ( FE_INVALID )
132is raised.
133.TP
134Range error: result overflow
135.\" .I errno
136.\" is set to
137.\" .BR ERANGE .
138An overflow floating-point exception
139.RB ( FE_OVERFLOW )
140is raised.
141.TP
142Range error: result underflow
143.\" .I errno
144.\" is set to
145.\" .BR ERANGE .
146An underflow floating-point exception
147.RB ( FE_UNDERFLOW )
148is raised.
149.PP
150These 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
155These functions first appeared in glibc in version 2.1.
cc610618
PH
156.SH ATTRIBUTES
157.SS Multithreading (see pthreads(7))
158The
159.BR fma (),
160.BR fmaf (),
161and
162.BR fmal ()
163functions are thread-safe.
47297adb 164.SH CONFORMING TO
6bd01965 165C99, POSIX.1-2001.
47297adb 166.SH SEE ALSO
fea681da
MK
167.BR remainder (3),
168.BR remquo (3)