```1`fma(3M)                 Mathematical Library Functions                 fma(3M)`
2
3
4
```

## NAME

```6`       fma, fmaf, fmal - floating-point multiply-add`
7
```

## SYNOPSIS

```9`       c99 [ flag... ] file... -lm [ library... ]`
10`       #include <math.h>`
11
12`       double fma(double x, double y, double z);`
13
14
15`       float fmaf(float x, float y, float z);`
16
17
18`       long double fmal(long double x, long double y, long double z);`
19
20
```

## DESCRIPTION

```22`       These  functions compute (x * y) + z, rounded as one ternary operation.`
23`       They compute the value (as if) to infinite precision and round once  to`
24`       the  result format, according to the rounding mode characterized by the`
25`       value of FLT_ROUNDS.`
26
```

## RETURN VALUES

```28`       Upon successful completion, these functions return (x * y) + z, rounded`
29`       as one ternary operation.`
30
31
32`       If x or y are NaN, a NaN is returned.`
33
34
35`       If x multiplied by y is an exact infinity and z is also an infinity but`
36`       with the opposite sign, a domain error occurs and a NaN is returned.`
37
38
39`       If one of x and y is infinite, the other is 0, and z is not  a  NaN,  a`
40`       domain error occurs and a NaN is returned.`
41
42
43`       If x*y is not 0*Inf nor Inf*0 and z is a NaN, a NaN is returned.`
44
```

## ERRORS

```46`       These functions will fail if:`
47
48`       Domain Error    The  value  of  x*y+z  is  invalid  or the value x*y is`
49`                       invalid.`
50
51`                       If   the   integer   expression   (math_errhandling   &`
52`                       MATH_ERREXCEPT) is non-zero, the invalid floating-point`
53`                       exception will be raised.`
54
55
56`       Range Error     The result overflows.`
57
58`                       If   the   integer   expression   (math_errhandling   &`
59`                       MATH_ERREXCEPT)  is  non-zero,  the  overflow floating-`
60`                       point exception will be raised.`
61
62
```

## USAGE

```64`       An application wanting to check for exceptions should  call  feclearex‐`
65`       cept(FE_ALL_EXCEPT)  before  calling  these  functions.  On  return, if`
66`       fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is`
67`       non-zero,  an  exception  has been raised. An application should either`
68`       examine the return value or check the floating point exception flags to`
69`       detect exceptions.`
70
```

## ATTRIBUTES

```72`       See attributes(5) for descriptions of the following attributes:`
73
74
75
76
77`       ┌─────────────────────────────┬─────────────────────────────┐`
78`       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │`
79`       ├─────────────────────────────┼─────────────────────────────┤`
80`       │Interface Stability          │Standard                     │`
81`       ├─────────────────────────────┼─────────────────────────────┤`
82`       │MT-Level                     │MT-Safe                      │`
83`       └─────────────────────────────┴─────────────────────────────┘`
84
```

```86`       feclearexcept(3M),   fetestexcept(3M),   math.h(3HEAD),  attributes(5),`
87`       standards(5)`
91`SunOS 5.11                        12 Jul 2006                          fma(3M)`