fma(), fmaf()

fused multiply-add 

Function


SYNOPSIS

#include <math.h>

float fmaf(float x, float y, float z)

double fma(double x, double y, double z)


DESCRIPTION

The fma(), and fmaf() functions return (x * y) + z, computed with only one rounding error. Using the ordinary multiplication and addition operators, 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 infinity 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 performance on machines that implement it natively. The macros FP_FAST_FMA, FP_FAST_FMAF and FP_FAST_FMAL may be defined in <math.h> to indicate that fma(), and fmaf() (respectively) have comparable or faster speed than a multiply operation followed by an add operation.


CONFORMANCE

fma() and fmaf() functions conform to ANSI/ISO 9899:1999 'ISO C99'.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
fenv(), math()


PTC MKS Toolkit 10.4 Documentation Build 39.