fma(3)
๐ fma(3) โ floating-point multiply and add ๐
okay bestie, welcome to the fma(3) page, she's a <math.h> icon and honestly? underrated.
โจ NAME โจ
fma, fmaf, fmal โ floating-point multiply and add ๐งฎโจ
๐ LIBRARY ๐
Math library (libm, link it with -lm) โ yeah you gotta bring the -lm or she simply will not show up, no cap.
๐ธ SYNOPSIS ๐ธ
#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);
๐ง Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
fma(),fmaf(),fmal():_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
like, define one of those or she's not coming out to play, iykyk ๐
๐ซ DESCRIPTION ๐ซ
These functions compute x * y + z. and here's the serving part: the result is rounded as ONE ternary operation according to the current rounding mode (see fenv(3)).
translation: she does the whole multiply-then-add as a single glow-up, one rounding, not two. that's the whole point. main character energy fr fr ๐
๐ฆ RETURN VALUE ๐ฆ
- She returns the value of
x * y + z, rounded as one ternary operation. periodt. - If
xoryis a NaN, a NaN is returned. ๐ - If
xtimesyis an exact infinity, andzis an infinity with the opposite sign, a domain error occurs, and a NaN is returned. ๐ - If one of
xoryis an infinity, the other is0, andzis not a NaN, a domain error occurs, and a NaN is returned. ๐ - If one of
xoryis an infinity, and the other is0, andzis a NaN, a domain error occurs, and a NaN is returned. ๐ - If
xtimesyis not an infinity times zero (or vice versa), andzis a NaN, a NaN is returned. - If the result overflows, a range error occurs, and an infinity with the correct sign is returned.
- If the result underflows, a range error occurs, and a signed
0is returned.
๐จ ERRORS ๐จ
Go read math_error(7) if you wanna know how to figure out whether an error actually happened when you called these functions. that's the detective work, bestie ๐
The following errors can occur:
- Domain error:
x * y + zorx * yis invalid.- An invalid floating-point exception (
FE_INVALID) is raised.
- An invalid floating-point exception (
- Range error: result overflow
- An overflow floating-point exception (
FE_OVERFLOW) is raised.
- An overflow floating-point exception (
- Range error: result underflow
- An underflow floating-point exception (
FE_UNDERFLOW) is raised.
- An underflow floating-point exception (
โ ๏ธ These functions do not set errno. not even a little. don't go checking it, she said no ๐ญ
๐ ATTRIBUTES ๐
For an explanation of the terms used in this section, see attributes(7).
fma(),fmaf(),fmal()โ Thread safety:MT-Safe๐ซถ
(yes queen, she's MT-Safe, go off in all your threads simultaneously, she can handle it โจ)
๐ STANDARDS ๐
C11, POSIX.1-2008. certified, official, iconic. ๐
๐ HISTORY ๐
glibc 2.1. C99, POSIX.1-2001. she's been here since forever and she's been correct the whole time ๐ฐ๏ธโจ
๐ฅ SEE ALSO ๐ฅ
and that's the whole page, bestie!! you ate that. ๐ this little love letter comes straight from Linux man-pages 6.20, dated 2026-02-08 โ mwah, go round some floats correctly ๐ง๐ธ๐ฆ
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: GPL-1.0-or-later
- Copyright 2002, Walter Harms <walter.harms@informatik.uni-oldenburg.de>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms