carg(3)

✨ carg(3) ✨

okay bestie, welcome to the Linux Library Functions Manual πŸ’– you're here for carg, cargf, and cargl, and honestly? they're about to eat. no cap.


🌸 NAME 🌸

carg, cargf, cargl β€” calculate the complex argument πŸ’…


πŸŽ€ LIBRARY πŸŽ€

Math library (libm, -lm)

like, link it, obviously. -lm. don't forget. iykyk. 🫢


✨ SYNOPSIS ✨

#include <complex.h>

double carg(double complex z);
float cargf(float complex z);
long double cargl(long double complex z);

three of them. one for each size of dramatic. double, float, long double. slay. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so these functions calculate the complex argument of z β€” which, pro tip, is also called the phase angle β€” and there's a branch cut along the negative real axis, which is the drama of it all. 🌈

here's the vibe: a complex number can be described by two real coordinates, and you can pick your flavor.

flavor one: rectangular coordinates πŸ“ and you get

z = x + I * y

where x = creal(z) and y = cimag(z).

flavor two: polar coordinates πŸ“ and you get

z = r * cexp(I * a)

where r = cabs(z) is the "radius", the "modulus", literally the absolute value of z β€” and a = carg(z) is the "phase angle", the argument of z. it's giving main character energy for real. 🌟

and the way that these two relate?? 🫣

tan(carg(z)) = cimag(z) / creal(z)

periodt. πŸ’…


πŸ’– RETURN VALUE πŸ’–

the return value is in the range of [-pi,pi]. that's it, that's the tea. β˜• not me being precise about it.


⭐ ATTRIBUTES ⭐

for an explanation of the terms used in this section, go look at attributes(7) β€” it's like the group chat glossary bestie, very helpful.

the girls are thread safe, no notes:

  • carg(), cargf(), cargl() β€” Thread safety: MT-Safe πŸ”₯

πŸ‘‘ STANDARDS πŸ‘‘

C11, POSIX.1-2008.

certified. iconic. πŸ’œ


🌈 HISTORY 🌈

  • glibc 2.1.
  • C99, POSIX.1-2001.

so it's been around forever, a true veteran, a legend lowkey. πŸ™ˆ


🧚 SEE ALSO 🧚

go read the friends, they're part of the same little universe bestie. πŸ¦‹


k that's the whole page, go forth and compute your phase angles, i'm obsessed with you fr fr πŸ’–

Linux man-pages 6.20 Β· 2026-02-08 β€” okay so that's the version and the date, clocked, timestamped, and it's giving official. bye bestie, love you, drink water! πŸŽ€βœ¨πŸ«Ά

πŸ“¦ 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