Namespaces
Variants
Views
Actions

From cppreference.com
< c‎ | numeric‎ | complex
Defined in header <complex.h>
#define I /* unspecified */
(since C99)

The I macro expands to either Complex_I or Imaginary_I. If the implementation does not support imaginary types, then the macro always expands to Complex_I.

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

[edit] Example

#include <stdio.h>
#include <complex.h>
 
int main(void)
{
    #ifdef __STDC_NO_COMPLEX__
            printf("__STDC_NO_COMPLEX__ is defined.\n");
    #else
        printf("__STDC_NO_COMPLEX__ is undefined.\n");
    #endif
 
    #ifdef __STDC_IEC_559_COMPLEX__
        printf("__STDC_IEC_559_COMPLEX__ is defined.\n");
    #else
        printf("__STDC_IEC_559_COMPLEX__ is undefined.\n");
    #endif
 
    printf("I = %.1f%+.1fi\n", creal(I), cimag(I));
    printf("sizeof(I) = %zu\n", sizeof(I));  
    printf("sizeof(_Complex_I) = %zu\n", sizeof(_Complex_I));
 
    double complex z = 1.0 + 2.0*I;
    printf("z = %.1f%+.1fi\n", creal(z), cimag(z));
 
    return 0;
}

Output:

__STDC_NO_COMPLEX__ is undefined.
__STDC_IEC_559_COMPLEX__ is defined.
I = 0.0+1.0i
sizeof(I) = 8
sizeof(_Complex_I) = 8
z = 1.0+2.0i

[edit] See also

the imaginary unit constant i
(macro constant) [edit]
the complex unit constant i
(macro constant) [edit]
(C11)(C11)(C11)
constructs a complex number from real and imaginary parts
(function macro) [edit]
C++ documentation for operator""i