Skip to content

Latest commit

 

History

History
104 lines (77 loc) · 3.47 KB

fma-fmaf-fmal.md

File metadata and controls

104 lines (77 loc) · 3.47 KB
titledescriptionms.dateapi_nameapi_locationapi_typetopic_typef1_keywordshelpviewer_keywordsms.assetid
fma, fmaf, fmal
API reference for fma, fmaf, and fmal; which multiplies two values together, adds a third value, and then rounds the result, while only losing a small amount of precision due to intermediary rounding.
9/1/2020
fma
fmaf
fmal
_o_fma
_o_fmaf
_o_fmal
msvcrt.dll
msvcr80.dll
msvcr90.dll
msvcr100.dll
msvcr100_clr0400.dll
msvcr110.dll
msvcr110_clr0400.dll
msvcr120.dll
msvcr120_clr0400.dll
ucrtbase.dll
api-ms-win-crt-math-l1-1-0.dll
DLLExport
apiref
fma
fmaf
fmal
math/fma
math/fmaf
math/fmal
fma function
fmaf function
fmal function
584a6037-da1e-4e86-9f0c-97aae86de0c0

fma, fmaf, fmal

Multiplies two values together, adds a third value, and then rounds the result, while only losing a small amount of precision due to intermediary rounding.

Syntax

doublefma( doublex, doubley, doublez ); floatfma( floatx, floaty, floatz ); //C++ onlylong doublefma( long doublex, long doubley, long doublez ); //C++ onlyfloatfmaf( floatx, floaty, floatz ); long doublefmal( long doublex, long doubley, long doublez ); #definefma(X, Y, Z) // Requires C11 or higher

Parameters

x
The first value to multiply.

y
The second value to multiply.

z
The value to add.

Return value

Returns approximately (x * y) + z. The return value is then rounded using the current rounding format, although in many cases, it returns incorrectly rounded results and thus the value may be inexact by up to half an ulp from the correct value.

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.

Remarks

Because C++ allows overloading, you can call overloads of fma that take and return float and long double types. In a C program, unless you're using the <tgmath.h> macro to call this function, fma always takes and returns a double.

If you use the <tgmath.h> fma() macro, the type of the argument determines which version of the function is selected. See Type-generic math for details.

This function computes the value as though it were taken to infinite precision, and then rounds the final result.

By default, this function's global state is scoped to the application. To change this behavior, see Global state in the CRT.

Requirements

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

For more compatibility information, see Compatibility.

See also

Alphabetical function reference
remainder, remainderf, remainderl
remquo, remquof, remquol

close