.\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
.\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
.\" <mtk.manpages@gmail.com>
-.\" Distributed under GPL, 2002-07-27 Walter Harms
+.\"
+.\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
+.\" Distributed under GPL
+.\" %%%LICENSE_END
+.\"
.\" Modified 2004-11-15, Added further text on FLT_ROUNDS
.\" as suggested by AEB and Fabian Kreutz
.\"
-.TH FMA 3 2008-08-05 "" "Linux Programmer's Manual"
+.TH FMA 3 2017-09-15 "" "Linux Programmer's Manual"
.SH NAME
fma, fmaf, fmal \- floating-point multiply and add
.SH SYNOPSIS
.nf
.B #include <math.h>
-.sp
+.PP
.BI "double fma(double " x ", double " y ", double " z );
-.br
.BI "float fmaf(float " x ", float " y ", float " z );
-.br
.BI "long double fmal(long double " x ", long double " y ", long double " z );
.fi
-.sp
+.PP
Link with \fI\-lm\fP.
-.sp
+.PP
.in -4n
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.in
-.sp
+.PP
.ad l
.BR fma (),
.BR fmaf (),
.BR fmal ():
-_XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE; or
-.I cc\ -std=c99
-.ad b
+.RS 4
+_ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
+.RE
+.ad
.SH DESCRIPTION
-The
-.BR fma ()
-function computes
+These functions compute
.IR x " * " y " + " z .
The result is rounded as one ternary operation according to the
-rounding mode determined by the value of
-.BR FLT_ROUNDS .
-.B FLT_ROUNDS
-indicates the implementation-defined rounding
-behavior for floating-point addition,
-and has one of the following values:
-.IP \-1
-The rounding mode is not determinable.
-.IP 0
-Rounding is towards 0.
-.IP 1
-Rounding is towards nearest number.
-.IP 2
-Rounding is towards positive infinity.
-.IP 3
-Rounding is towards negative infinity.
-.PP
-Other values represent machine-dependent, non-standard rounding modes.
+current rounding mode (see
+.BR fenv (3)).
.SH RETURN VALUE
These functions return the value of
.IR x " * " y " + " z ,
rounded as one ternary operation.
-
+.PP
If
.I x
or
.I y
is a NaN, a NaN is returned.
-
+.PP
If
.I x
times
is an infinity with the opposite sign,
a domain error occurs,
and a NaN is returned.
-
+.PP
+.\" POSIX.1-2008 allows some possible differences for the following two
+.\" domain error cases, but on Linux they are treated the same (AFAICS).
+.\" Nevertheless, we'll mirror POSIX.1 and describe the two cases
+.\" separately.
If one of
.I x
or
is not a NaN,
a domain error occurs, and
a NaN is returned.
-
+.\" POSIX.1 says that a NaN or an implementation-defined value shall
+.\" be returned for this case.
+.PP
If one of
.I x
or
.\" POSIX.1 makes the domain error optional for this case.
a domain error occurs, and
a NaN is returned.
-
+.PP
If
.I x
times
.I z
is a NaN,
a NaN is returned.
-
+.PP
If the result overflows,
a range error occurs, and
an infinity with the correct sign is returned.
-
+.PP
If the result underflows,
a range error occurs, and
a signed 0 is returned.
.IR errno .
.\" FIXME . Is it intentional that these functions do not set errno?
.\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6801
-.SH "CONFORMING TO"
-C99, POSIX.1-2001.
-.SH "SEE ALSO"
+.SH VERSIONS
+These functions first appeared in glibc in version 2.1.
+.SH ATTRIBUTES
+For an explanation of the terms used in this section, see
+.BR attributes (7).
+.TS
+allbox;
+lbw21 lb lb
+l l l.
+Interface Attribute Value
+T{
+.BR fma (),
+.BR fmaf (),
+.BR fmal ()
+T} Thread safety MT-Safe
+.TE
+.SH CONFORMING TO
+C99, POSIX.1-2001, POSIX.1-2008.
+.SH SEE ALSO
.BR remainder (3),
.BR remquo (3)