Namespaces
Variants
Actions

complex

From cppreference.com
< c‎ | numeric‎ | complex
 
 
 
Complex number arithmetic
Types and the imaginary constant
complex
(C99)
(C99)    
(C11)
(C99)
I
(C99)
Manipulation
(C99)
(C99)
(C99)
(C99)
(C99)
(C99)
Power and exponential functions
(C99)
(C99)
(C99)
(C99)
Trigonometric functions
(C99)
(C99)
(C99)
(C99)
(C99)
(C99)
Hyperbolic functions
(C99)
(C99)
(C99)
(C99)
(C99)
(C99)
 
Defined in header <complex.h>
#define complex _Complex
(since C99)

This macro expands to a type specifier used to identify complex types.

A program may undefine and perhaps then redefine the complex macro.

[edit] Example

Run this code
#include <complex.h>
#include <math.h>
#include <stdio.h>
 
void print_complex(const char* note, complex z)
{
 printf ("%s %f%+f*i\n", note, creal (z), cimag (z));
}
 
int main(void)
{
 double complex z = -1.0 + 2.0*I;
 print_complex("z =", z);
 print_complex("z\u00B2 =", z * z);
 double complex z2 = ccos (2.0 * carg (z)) + csin (2.0 * carg (z))*I;
 print_complex("z\u00B2 =", cabs (z) * cabs (z) * z2);
}

Output:

z = -1.000000+2.000000*i
z2 = -3.000000-4.000000*i
z2 = -3.000000-4.000000*i

[edit] References

  • C23 standard (ISO/IEC 9899:2024):
  • 7.3.1/4 complex (p: TBD)
  • C17 standard (ISO/IEC 9899:2018):
  • 7.3.1/4 complex (p: 136)
  • C11 standard (ISO/IEC 9899:2011):
  • 7.3.1/4 complex (p: 188)
  • C99 standard (ISO/IEC 9899:1999):
  • 7.3.1/2 complex (p: 170)

[edit] See also

imaginary type macro
(keyword macro) [edit]
Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/numeric/complex/complex&oldid=169480"

AltStyle によって変換されたページ (->オリジナル) /