CREAL(3POSIX)

πŸ’– CREAL(3POSIX) β€” the complex real functions πŸ’–

okay bestie, welcome to the POSIX Programmer's Manual, page CREAL(3POSIX). yes we're doing C math today and yes it's gonna be cute. sit down, grab a strawberry πŸ“, we're getting the real part out of a complex number and it's lowkey the easiest thing you'll do all day.


✨ PROLOG

so like, a little heads up first, no cap:

This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

translation: this is the POSIX version of the story, your Linux box might tell it a lil differently, and it might not even be implemented on Linux at all. check your local manpage, iykyk. 🫢


🌸 NAME

creal, crealf, creall β€” complex real functions

it's giving "extract the real part, that's the whole job." iconic honestly.


πŸŽ€ SYNOPSIS

#include <complex.h>

double creal(double complex z);
float crealf(float complex z);
long double creall(long double complex z);

three flavours, one vibe: double, float, long double. pick your size bestie πŸ’…


πŸ¦‹ DESCRIPTION

okay so first things first, the boring-but-important part:

The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional. This volume of POSIX.1‐2017 defers to the ISO C standard.

basically if this page and the ISO C standard ever beef, ISO C wins. not me making the rules, that's just how it is 😭

and now the actual tea:

These functions shall compute the real part of z.

that's it. that's the function. you hand it a complex number, it hands you back the real half. main character energy, zero drama. ✨


πŸ’œ RETURN VALUE

These functions shall return the real part value.

like, the actual number. the real one. slay. πŸ‘‘


πŸ’€ ERRORS

No errors are defined.

not a single one. it literally cannot fail at this. we love a low-maintenance function fr fr.

The following sections are informative.

(so everything from here down is like, extra context, not requirements. noted bestie πŸ“)


🌈 EXAMPLES

None.

yeah they left us on read for this one πŸ™ˆ no example, no problem, we move.


🧚 APPLICATION USAGE

here's the one little gem they DID give us β€” for a variable z of type complex:

z == creal(z) + cimag(z)*I

so your complex number is literally just its real part plus its imaginary part times I. put that in your notes app and highlight it, it's that kind of fact. πŸ”₯


⭐ RATIONALE

None.

no rationale, no explanation, no lore. the function simply is. mysterious. ethereal. we stan a quiet queen. πŸŽ€


πŸ•° FUTURE DIRECTIONS

None.

the future holds... nothing for this function. it's perfect as-is and it knows it. periodt. πŸ’…


πŸ‘€ SEE ALSO

go give these besties a visit, they're all in the complex-number group chat:

  • carg()
  • cimag()
  • conj()
  • cproj()

and also, from the Base Definitions volume of POSIX.1‐2017:

  • <complex.h>

okay legal moment, don't scroll, this matters:

Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .

and that's the whole page, bestie!! 🫢 this one came to you from IEEE/The Open Group, 2017 β€” CREAL(3POSIX), that's the one. go get that real part, you absolute icon πŸ’–βœ¨πŸŒΈπŸ¦‹