_Complex

From cppreference.com
< c‎ | language

Implements a complex-number type.

Contents

[edit] Syntax

float _Complex
double _Complex
long double _Complex

[edit] Explanation

There are three complex types, designated as float _Complex, double _Complex, and long double _Complex.

For each complex type, the corresponding real type is the type given by deleting the keyword _Complex from the type name.

Each complex type has the same representation and alignment requirements as an array type containing exactly two elements of the corresponding real type; the first element is equal to the real part, and the second element to the imaginary part, of the complex number.

If the conditional feature macro __STDC_NO_COMPLEX__ is defined, then the implementation does not support complex types or the <complex.h> header.

[edit] Keywords

_Complex, float, double, long

[edit] Example

#include <stdio.h>
 
int main(void)
{
    printf("sizeof(_Complex float)       = %2zu\n", sizeof(_Complex float));
    printf("sizeof(_Complex double)      = %2zu\n", sizeof(_Complex double));
    printf("sizeof(_Complex long double) = %2zu\n", sizeof(_Complex long double));
 
    _Complex float zf;
    _Complex double zd;
    _Complex long double zld;
 
    double _Complex z;   /* also works */
 
    return 0;
}

Possible output:

sizeof(_Complex float)       =  8
sizeof(_Complex double)      = 16
sizeof(_Complex long double) = 32