1fma(3) Library Functions Manual fma(3)
2
3
4
6 fma, fmaf, fmal - floating-point multiply and add
7
9 Math library (libm, -lm)
10
12 #include <math.h>
13
14 double fma(double x, double y, double z);
15 float fmaf(float x, float y, float z);
16 long double fmal(long double x, long double y, long double z);
17
18 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
19
20 fma(), fmaf(), fmal():
21 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
22
24 These functions compute x * y + z. The result is rounded as one
25 ternary operation according to the current rounding mode (see fenv(3)).
26
28 These functions return the value of x * y + z, rounded as one ternary
29 operation.
30
31 If x or y is a NaN, a NaN is returned.
32
33 If x times y is an exact infinity, and z is an infinity with the oppo‐
34 site sign, a domain error occurs, and a NaN is returned.
35
36 If one of x or y is an infinity, the other is 0, and z is not a NaN, a
37 domain error occurs, and a NaN is returned.
38
39 If one of x or y is an infinity, and the other is 0, and z is a NaN, a
40 domain error occurs, and a NaN is returned.
41
42 If x times y is not an infinity times zero (or vice versa), and z is a
43 NaN, a NaN is returned.
44
45 If the result overflows, a range error occurs, and an infinity with the
46 correct sign is returned.
47
48 If the result underflows, a range error occurs, and a signed 0 is re‐
49 turned.
50
52 See math_error(7) for information on how to determine whether an error
53 has occurred when calling these functions.
54
55 The following errors can occur:
56
57 Domain error: x * y + z, or x * y is invalid and z is not a NaN
58 An invalid floating-point exception (FE_INVALID) is raised.
59
60 Range error: result overflow
61 An overflow floating-point exception (FE_OVERFLOW) is raised.
62
63 Range error: result underflow
64 An underflow floating-point exception (FE_UNDERFLOW) is raised.
65
66 These functions do not set errno.
67
69 For an explanation of the terms used in this section, see at‐
70 tributes(7).
71
72 ┌────────────────────────────────────────────┬───────────────┬─────────┐
73 │Interface │ Attribute │ Value │
74 ├────────────────────────────────────────────┼───────────────┼─────────┤
75 │fma(), fmaf(), fmal() │ Thread safety │ MT-Safe │
76 └────────────────────────────────────────────┴───────────────┴─────────┘
77
79 C11, POSIX.1-2008.
80
82 glibc 2.1. C99, POSIX.1-2001.
83
85 remainder(3), remquo(3)
86
87
88
89Linux man-pages 6.04 2023-03-30 fma(3)