cimag(3)
π cimag β get the imaginary part of a complex number π
okay bestie, so you know how complex numbers are like, a real part plus an imaginary part? yeah. this page is about grabbing that imaginary half. that's it, that's the whole job. it's giving "small but mighty". β¨
π LIBRARY
Math library β you link it with -lm. don't forget her, she's not gonna link herself. π
β¨ SYNOPSIS β¨
#include <complex.h>
double cimag(double complex z);
float cimagf(float complex z);
long double cimagl(long double complex z);
π«Ά DESCRIPTION
so these three functions return the imaginary part of the complex number z. that's it. that's the function. no drama, no plot twist, just vibes.
and fyi, this identity is literally always true:
z = creal(z) + I * cimag(z)
likeβ¦ that's just what a complex number is. creal(z) gives you the real bit (cabs-girlies know), I * cimag(z) gives you the imaginary bit, add them up and boom, you got z back. math ate and left no crumbs. π
π§΅ ATTRIBUTES
if you're like "bestie what does attribute even mean here", go read attributes(7) for the whole explanation. no cap.
here's the tea for these specific functions:
cimag(),cimagf(),cimagl()β Thread safety: MT-Safe β
so yeah, they're MT-Safe. thread-safe. go wild (responsibly). π¦
πΈ VERSIONS
fun fact: GCC also supports __imag__. but heads up bestie β that one is a GNU extension, so it's not the standard flex. β
π STANDARDS
- C11
- POSIX.1-2008
periodt. π
π HISTORY
- glibc 2.1
- C99
- POSIX.1-2001
so she's been around a while. iconic behavior honestly. π₯
π SEE ALSO
reminder: this page is aboutcimag,cimagfandcimagl. don't rock up trying to callcimag()on a plaindoubleβ she needs an actual complex number, bestie. π
okay that's the whole page!! π and for the cute lil sign-off: this one came from the Linux man-pages 6.20 era, dated 2026-02-08. mwah. πβ¨π
π¦ 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