_Complex_I
Von cppreference.com
| Definiert im Header <complex.h> |
||
| #define _Complex_I /* nicht spezifiziert */ |
(seit C99) | |
Das Makro _Complex_I expandiert zu einem Wert vom Typ const float _Complex mit dem Wert der imaginären Einheit.
Inhalt |
[bearbeiten] Hinweise
Dieses Makro kann verwendet werden, wenn I nicht verfügbar ist, z. B. wenn es von der Anwendung undefiniert wurde.
Im Gegensatz zu _Imaginary_I und CMPLX kann die Verwendung dieses Makros zur Konstruktion einer komplexen Zahl das Vorzeichen von Null für den imaginären Teil verlieren.
[bearbeiten] Beispiel
Führen Sie diesen Code aus
#include <stdio.h> #include <complex.h> #undef I #define J _Complex_I // can be used to redefine I int main(void) { // can be used to construct a complex number double complex z = 1.0 + 2.0 * _Complex_I; printf("1.0 + 2.0 * _Complex_I = %.1f%+.1fi\n", creal(z), cimag(z)); // sign of zero may not be preserved double complex z2 = 0.0 + -0.0 * _Complex_I; printf("0.0 + -0.0 * _Complex_I = %.1f%+.1fi\n", creal(z2), cimag(z2)); }
Mögliche Ausgabe
1.0 + 2.0 * _Complex_I = 1.0+2.0i 0.0 + -0.0 * _Complex_I = 0.0+0.0i
[bearbeiten] Referenzen
- C23-Standard (ISO/IEC 9899:2024)
- 7.3.1/4 _Complex_I (S. TBD)
- C17-Standard (ISO/IEC 9899:2018)
- 7.3.1/4 _Complex_I (S. 136)
- C11-Standard (ISO/IEC 9899:2011)
- 7.3.1/4 _Complex_I (S. 188)
- C99-Standard (ISO/IEC 9899:1999)
- 7.3.1/2 _Complex_I (S. 170)
[bearbeiten] Siehe auch
| (C99) |
die imaginäre Einheit konstante i (Makro-Konstante) |
| (C99) |
die komplexe oder imaginäre Einheit konstante i (Makro-Konstante) |