fmad32(), fmad64(), fmad128() — Multiply then add
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
C/C++ DFP | both | z/OS V1.11 |
Format
#define __STDC_WANT_DEC_FP__
#include <math.h>
_Decimal32 fmad32(_Decimal32 x, _Decimal32 y, _Decimal32 z);
_Decimal64 fmad64(_Decimal64 x, _Decimal64 y, _Decimal64 z);
_Decimal128 fmad128(_Decimal128 x, _Decimal128 y, _Decimal128 z);
_Decimal32 fma(_Decimal32 x, _Decimal32 y, _Decimal32 z); /* C++ only */
_Decimal64 fma(_Decimal64 x, _Decimal64 y, _Decimal64 z); /* C++ only */
_Decimal128 fma(_Decimal128 x, _Decimal128 y, _Decimal128 z); /* C++ only */
General description
The fma() family of functions compute (x * y) + z rounded as one ternary operation: they compute the value to infinite precision and round once to the resulting format according to the current rounding mode.
Notes:
- These functions work in IEEE decimal floating-point format. See IEEE decimal floating-pointIEEE Decimal Floating-Point for more information.
- To use IEEE decimal floating-point, the hardware must have the Decimal Floating-Point Facility installed.
Returned value
If successful, they return the rounded value of (x * y) + z as one ternary operation.
Example
/* CELEBF82
This example illustrates the fmad64() function.
*/
#define __STDC_WANT_DEC_FP__
#include <math.h>
#include <stdio.h>
void main(void)
{
_Decimal64 w, x, y, z;
x = 2.5DD;
y = 6.7DD;
z = 1.0DD;
w = fmad64(x,y,z);
printf("fmad64( %Df, %Df, %Df ) = %Df\n", x, y, z, w);
}