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 x or y is a NaN, a NaN is returned. ๐Ÿ™ˆ
  • If x times y is an exact infinity, and z is an infinity with the opposite sign, a domain error occurs, and a NaN is returned. ๐Ÿ’€
  • If one of x or y is an infinity, the other is 0, and z is not a NaN, a domain error occurs, and a NaN is returned. ๐Ÿ’€
  • If one of x or y is an infinity, and the other is 0, and z is a NaN, a domain error occurs, and a NaN is returned. ๐Ÿ’€
  • If x times y is not an infinity times zero (or vice versa), and z is 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 0 is 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 + z or x * y is invalid.
    • An invalid floating-point exception (FE_INVALID) is raised.
  • Range error: result overflow
    • An overflow floating-point exception (FE_OVERFLOW) is raised.
  • Range error: result underflow
    • An underflow floating-point exception (FE_UNDERFLOW) is raised.
โš ๏ธ 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
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms