Complex types

From cppreference.com
< c‎ | language

When a value of complex type is converted to another complex type, both the real and imaginary parts follow the conversion rules for the corresponding real types (see Real floating types).

[edit] Example

#include <stdio.h>
#include <float.h>
#include <complex.h>
 
int main(void)
{
    /* The value being converted can be represented exactly in the new type. */
    /* The value is unchanged in the new type.                               */
    double _Complex zd = 1.0 + 2.0*I;
    float _Complex zf = zd;
    printf("%.1f%+.1fi\n", crealf(zf),cimagf(zf));
 
    /* The value being converted is in the range of values that can be represented */
    /* in the new type but cannot be represented exactly.                          */
    /* implementation defined                                                      */
    zd = 1.23456789012345 + 1.23456789012345*I;
    printf("%.14f%+.14fi\n", creal(zd), cimag(zd));
    zf = zd;
    printf("%.14f%+.14fi\n", crealf(zf), cimagf(zf));
 
    /* The value being converted is outside the range of values that can be */
    /* represented in the type.                                             */
    /* undefined behavior                                                   */
    zd = DBL_MAX + DBL_MAX*I;
    zf = zd;
    printf("%.10f%+.10fi\n", crealf(zf), cimagf(zf));
 
    return 0;
}

Possible output:

1.0+2.0i
1.23456789012345+1.23456789012345i
1.23456788063049+1.23456788063049i
inf+infi