]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/fma.3
nfsservctl.2, getnameinfo.3, grantpt.3, ptsname.3, unlockpt.3, tzfile.5, ld.so.8...
[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>
fea681da 4.\" Distributed under GPL, 2002-07-27 Walter Harms
4022b76e
MK
5.\" Modified 2004-11-15, Added further text on FLT_ROUNDS
6.\" as suggested by AEB and Fabian Kreutz
fea681da 7.\"
50831f9b 8.TH FMA 3 2010-09-20 "" "Linux Programmer's Manual"
fea681da
MK
9.SH NAME
10fma, fmaf, fmal \- floating-point multiply and add
11.SH SYNOPSIS
12.nf
13.B #include <math.h>
14.sp
15.BI "double fma(double " x ", double " y ", double " z );
d39541ec 16.br
fea681da 17.BI "float fmaf(float " x ", float " y ", float " z );
d39541ec 18.br
fea681da
MK
19.BI "long double fmal(long double " x ", long double " y ", long double " z );
20.fi
21.sp
6bd01965
MK
22Link with \fI\-lm\fP.
23.sp
24.in -4n
25Feature Test Macro Requirements for glibc (see
26.BR feature_test_macros (7)):
27.in
28.sp
29.ad l
30.BR fma (),
31.BR fmaf (),
32.BR fmal ():
f1f0e4ed 33.RS 4
a5ea8d23
MK
34_XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
35_POSIX_C_SOURCE\ >=\ 200112L;
f1f0e4ed
MK
36.br
37or
6bd01965 38.I cc\ -std=c99
f1f0e4ed
MK
39.RE
40.ad
fea681da 41.SH DESCRIPTION
c13182ef 42The
63aa9df0 43.BR fma ()
fea681da
MK
44function computes
45.IR x " * " y " + " z .
6bd01965 46The result is rounded as one ternary operation according to the
00b5d372
MK
47current rounding mode (see
48.BR fenv (3)).
6bd01965
MK
49.SH RETURN VALUE
50These functions return the value of
51.IR x " * " y " + " z ,
52rounded as one ternary operation.
53
54If
55.I x
56or
57.I y
58is a NaN, a NaN is returned.
59
60If
61.I x
62times
63.I y
64is an exact infinity, and
65.I z
66is an infinity with the opposite sign,
efe294cb 67a domain error occurs,
6bd01965
MK
68and a NaN is returned.
69
c42ad30f
MK
70.\" POSIX.1-2008 allows some possible differences for the following two
71.\" domain error cases, but on Linux they are treated the same (AFAICS).
72.\" Nevertheless, we'll mirror POSIX.1 and describe the two cases
73.\" separately.
6bd01965
MK
74If one of
75.I x
76or
77.I y
78is an infinity, the other is 0, and
79.I z
80is not a NaN,
efe294cb 81a domain error occurs, and
6bd01965 82a NaN is returned.
c42ad30f
MK
83.\" POSIX.1 says that a NaN or an implementation-defined value shall
84.\" be returned for this case.
6bd01965
MK
85
86If one of
87.I x
88or
89.I y
90is an infinity, and the other is 0, and
91.I z
92is a NaN,
93.\" POSIX.1 makes the domain error optional for this case.
efe294cb 94a domain error occurs, and
6bd01965
MK
95a NaN is returned.
96
97If
98.I x
99times
100.I y
385cf745 101is not an infinity times zero (or vice versa), and
6bd01965
MK
102.I z
103is a NaN,
104a NaN is returned.
105
106If the result overflows,
efe294cb 107a range error occurs, and
6bd01965
MK
108an infinity with the correct sign is returned.
109
110If the result underflows,
efe294cb 111a range error occurs, and
6bd01965
MK
112a signed 0 is returned.
113.SH ERRORS
114See
115.BR math_error (7)
116for information on how to determine whether an error has occurred
117when calling these functions.
118.PP
119The following errors can occur:
120.TP
121Domain error: \fIx\fP * \fIy\fP + \fIz\fP, \
122or \fIx\fP * \fIy\fP is invalid and \fIz\fP is not a NaN
123.\" .I errno
124.\" is set to
125.\" .BR EDOM .
126An invalid floating-point exception
127.RB ( FE_INVALID )
128is raised.
129.TP
130Range error: result overflow
131.\" .I errno
132.\" is set to
133.\" .BR ERANGE .
134An overflow floating-point exception
135.RB ( FE_OVERFLOW )
136is raised.
137.TP
138Range error: result underflow
139.\" .I errno
140.\" is set to
141.\" .BR ERANGE .
142An underflow floating-point exception
143.RB ( FE_UNDERFLOW )
144is raised.
145.PP
146These functions do not set
147.IR errno .
148.\" FIXME . Is it intentional that these functions do not set errno?
149.\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6801
f0d7ce1d
MK
150.SH VERSIONS
151These functions first appeared in glibc in version 2.1.
47297adb 152.SH CONFORMING TO
6bd01965 153C99, POSIX.1-2001.
47297adb 154.SH SEE ALSO
fea681da
MK
155.BR remainder (3),
156.BR remquo (3)