fma, fmaf, fmal

Visual Studio 2015
 

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.

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.

Returns (x × y) + z. The return value is then rounded using the current rounding format.

Otherwise, may return one of the following values:

IssueReturn
x = INFINITY, y = 0 or

 x = 0, y = INFINITY
NaN
x or y = exact ± INFINITY, z = INFINITY with the opposite signNaN
x or y = NaNNaN
not (x = 0, y= indefinite) and z = NaN

not (x=indefinite, y=0) and z = NaN
NaN
Overflow range error±HUGE_VAL, ±HUGE_VALF, or ±HUGE_VALL
Underflow range errorcorrect value, after rounding.

Errors are reported as specified in _matherr.

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.

FunctionC headerC++ header
fma, fmaf, fmal<math.h><cmath>

For additional compatibility information, see Compatibility.

Alphabetical Function Reference
remainder, remainderf, remainderl
remquo, remquof, remquol

Show: