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