[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

# Technical Reference: Base Operating System and Extensions, Volume 1

## fma, fmaf, or fmal Subroutine

### Syntax

```#include <math.h>

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

float fmaf (x, y, z)
float x;
float y;
float z;

long double fmal (x, y, z)
long double x;
long double y;
long double z;
```

### Description

The fma, fmaf, and fmal subroutines compute (x * y) + z, rounded as one ternary operation. They compute the value (as if) to infinite precision and round once to the result format, according to the rounding mode characterized by the value of FLT_ROUNDS.

An application wishing to check for error situations should set the errno global variable to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these subroutines. Upon return, if errno is nonzero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is nonzero, an error has occurred.

### Parameters

 x Specifies the value to be multiplied by the y parameter. y Specifies the value to be multiplied by the x parameter. z Specifies the value to be added to the product of the x and y parameters.

### Return Values

Upon successful completion, the fma, fmaf, and fmal subroutines return (x * y) + z, rounded as one ternary operation.

If x or y are NaN, a NaN is returned.

If x multiplied by y is an exact infinity and z is also an infinity but with the opposite sign, a domain error occurs, and a NaN is returned.

If one of the x and y parameters is infinite, the other is zero, and the z parameter is not a NaN, a domain error occurs, and a NaN is returned.

If one of the x and y parameters is infinite, the other is zero, and z is a NaN, a NaN is returned and a domain error may occur.

If x*y is not 0*Inf nor Inf*0 and z is a NaN, a NaN is returned.

### Related Information

math.h in AIX 5L Version 5.2 Files Reference.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]