complex
From cppreference.net
Complex number arithmetic
| Types and the imaginary constant | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Manipulation | |||||||||||||||||||||||||||||||
| Power and exponential functions | |||||||||||||||||||||||||||||||
| Trigonometric functions | |||||||||||||||||||||||||||||||
| Hyperbolic functions | |||||||||||||||||||||||||||||||
|
Definiert im Header
<complex.h>
|
||
|
#define complex _Complex
|
(seit C99) | |
Dieses Makro expandiert zu einem Typspezifizierer, der verwendet wird, um komplexe Typen zu identifizieren.
Ein Programm kann das
complex
Makro undefinieren und möglicherweise anschließend neu definieren.
Beispiel
Diesen Code ausführen
#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); }
Ausgabe:
z = -1.000000+2.000000*i z² = -3.000000-4.000000*i z² = -3.000000-4.000000*i
Referenzen
- C23-Standard (ISO/IEC 9899:2024):
-
- 7.3.1/4 complex (S.: TBD)
- C17-Standard (ISO/IEC 9899:2018):
-
- 7.3.1/4 complex (S: 136)
- C11-Standard (ISO/IEC 9899:2011):
-
- 7.3.1/4 complex (S. 188)
- C99-Standard (ISO/IEC 9899:1999):
-
- 7.3.1/2 complex (S. 170)
Siehe auch
|
(C99)
|
Imaginärtyp-Makro
(Schlüsselwort-Makro) |