]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/fma.3
brk.2, chroot.2, clock_nanosleep.2, getpagesize.2, posix_fadvise.2, select.2, select_...
[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.\"
c73595c2 12.TH FMA 3 2015-04-19 "" "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
5600f73a 46These functions compute
fea681da 47.IR x " * " y " + " z .
6bd01965 48The result is rounded as one ternary operation according to the
00b5d372
MK
49current rounding mode (see
50.BR fenv (3)).
6bd01965
MK
51.SH RETURN VALUE
52These functions return the value of
53.IR x " * " y " + " z ,
54rounded as one ternary operation.
55
56If
57.I x
58or
59.I y
60is a NaN, a NaN is returned.
61
62If
63.I x
64times
65.I y
66is an exact infinity, and
67.I z
68is an infinity with the opposite sign,
efe294cb 69a domain error occurs,
6bd01965
MK
70and 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
76If one of
77.I x
78or
79.I y
80is an infinity, the other is 0, and
81.I z
82is not a NaN,
efe294cb 83a domain error occurs, and
6bd01965 84a 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
88If one of
89.I x
90or
91.I y
92is an infinity, and the other is 0, and
93.I z
94is a NaN,
95.\" POSIX.1 makes the domain error optional for this case.
efe294cb 96a domain error occurs, and
6bd01965
MK
97a NaN is returned.
98
99If
100.I x
101times
102.I y
385cf745 103is not an infinity times zero (or vice versa), and
6bd01965
MK
104.I z
105is a NaN,
106a NaN is returned.
107
108If the result overflows,
efe294cb 109a range error occurs, and
6bd01965
MK
110an infinity with the correct sign is returned.
111
112If the result underflows,
efe294cb 113a range error occurs, and
6bd01965
MK
114a signed 0 is returned.
115.SH ERRORS
116See
117.BR math_error (7)
118for information on how to determine whether an error has occurred
119when calling these functions.
120.PP
121The following errors can occur:
122.TP
123Domain error: \fIx\fP * \fIy\fP + \fIz\fP, \
124or \fIx\fP * \fIy\fP is invalid and \fIz\fP is not a NaN
125.\" .I errno
126.\" is set to
127.\" .BR EDOM .
128An invalid floating-point exception
129.RB ( FE_INVALID )
130is raised.
131.TP
132Range error: result overflow
133.\" .I errno
134.\" is set to
135.\" .BR ERANGE .
136An overflow floating-point exception
137.RB ( FE_OVERFLOW )
138is raised.
139.TP
140Range error: result underflow
141.\" .I errno
142.\" is set to
143.\" .BR ERANGE .
144An underflow floating-point exception
145.RB ( FE_UNDERFLOW )
146is raised.
147.PP
148These 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
153These functions first appeared in glibc in version 2.1.
cc610618 154.SH ATTRIBUTES
d2d44c15
MK
155For an explanation of the terms used in this section, see
156.BR attributes (7).
157.TS
158allbox;
159lbw21 lb lb
160l l l.
161Interface Attribute Value
162T{
cc610618
PH
163.BR fma (),
164.BR fmaf (),
cc610618 165.BR fmal ()
d2d44c15
MK
166T} Thread safety MT-Safe
167.TE
47297adb 168.SH CONFORMING TO
9a74e018 169C99, POSIX.1-2001, POSIX.1-2008.
47297adb 170.SH SEE ALSO
fea681da
MK
171.BR remainder (3),
172.BR remquo (3)