fma, fmaf, fmal
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at fma, fmaf, fmal.
Multiplies two values together, adds a third value, and then rounds the result, without losing any precision due to intermediary rounding.
Syntax
double fma(
double x,
double y,
double z
);
float fma(
float x,
float y,
float z
); //C++ only
long double fma(
long double x,
long double y,
long double z
); //C++ only
float fmaf(
float x,
float y,
float z
);
long double fmal(
long double x,
long double y,
long double z
);
Parameters
[in] x
The first value to multiply.
[in] y
The second value to multiply.
[in] z
The value to add.
Return Value
Returns (x
× y
) + z
. The return value is then rounded using the current rounding format.
Otherwise, may return one of the following values:
Issue | Return |
---|---|
x = INFINITY, y = 0 orx = 0, y = INFINITY |
NaN |
x or y = exact ± INFINITY, z = INFINITY with the opposite sign |
NaN |
x or y = NaN |
NaN |
not (x = 0, y = indefinite) and z = NaNnot ( x =indefinite, y =0) and z = NaN |
NaN |
Overflow range error | ±HUGE_VAL, ±HUGE_VALF, or ±HUGE_VALL |
Underflow range error | correct value, after rounding. |
Errors are reported as specified in _matherr.
Remarks
Because C++ allows overloading, you can call overloads of fma
that take and return float and long double types. In a C program, fma
always takes and returns a double.
This function computes the value as though it were taken to infinite precision, and then rounds the final result.
Requirements
Function | C header | C++ header |
---|---|---|
fma , fmaf , fmal |
<math.h> | <cmath> |
For additional compatibility information, see Compatibility.
See Also
Alphabetical Function Reference
remainder, remainderf, remainderl
remquo, remquof, remquol