FreeBSD Manual Pages
FMA(3) BSD Library Functions Manual FMA(3) NAME fma, fmaf -- fused multiply-add LIBRARY Math Library (libm, -lm) SYNOPSIS #include <math.h> double fma(double x, double y, double z); float fmaf(float x, float y, float z); DESCRIPTION The fma() and fmaf() functions return (x * y) + z, computed with only one rounding error. Using the ordinary multiplication and addition opera- tors, by contrast, results in two roundings: one for the intermediate product and one for the final result. For instance, the expression 1.2e100 * 2.0e208 - 1.4e308 produces infin- ity due to overflow in the intermediate product, whereas fma(1.2e100, 2.0e208, -1.4e308) returns approximately 1.0e308. The fused multiply-add operation is often used to improve the accuracy of calculations such as dot products. It may also be used to improve per- formance on machines that implement it natively. The macros FP_FAST_FMA and FP_FAST_FMAF may be defined in <math.h> to indicate that fma() and fmaf() (respectively) have comparable or faster speed than a multiply op- eration followed by an add operation. IMPLEMENTATION NOTES In general, fma() and fmaf() will behave as one would expect if x * y + z were computed with unbounded precision and range, then rounded to the precision of the return type. However, on some platforms, if z is NaN, these functions may not raise an exception even when the computation of x * y would have otherwise generated an invalid exception. SEE ALSO fenv(3), math(3) STANDARDS The fma() and fmaf() functions conform to ISO/IEC 9899:1999 ("ISO C99"). A fused multiply-add operation with virtually identical characteristics appears in IEEE draft standard 754R. HISTORY These routines first appeared in FreeBSD 5.4. BSD January 22, 2005 BSD
NAME | LIBRARY | SYNOPSIS | DESCRIPTION | IMPLEMENTATION NOTES | SEE ALSO | STANDARDS | HISTORY
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=fma&sektion=3&manpath=FreeBSD+5.4-RELEASE>