fma(), fmaf(), fmal() — Multiply then add

Standards

Standards / Extensions C or C++ Dependencies

C99
Single UNIX Specification, Version 3
C++ TR1 C99

both  z/OS V1R7

Format

#define _ISOC99_SOURCE
#include <math.h>

double fma(double x, double y, double z);
float fmaf(float x, float y, float z);
long double fmal(long double x, long double y, long double z);
C++ TR1 C99:
#define _TR1_C99
#include <math.h>

float fma(float x, float y, float z); 
long double fma(long double x, long double y, long double z);

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 rounding mode characterized by the value of FLT_ROUNDS.
Note: The following table shows the viable formats for these functions. See IEEE binary floating-point for more information about IEEE Binary Floating-Point.
Function Hex IEEE
fma X X
fmaf X X
fmal X X
Restriction: The fmaf() function does not support the _FP_MODE_VARIABLE feature test macro.

Returned value

If successful, they return the rounded value of (x * y) + z as one ternary operation.

Related information