Names specified here
Name Description Notes Source Availability
_Imaginary Type specifier for imaginary types L ? Q Keyword C99 C11
_Imaginary_I Square root of −1 ? M <complex.h> C99 C11
imaginary Modifier for imaginary types ? M Q <complex.h> C99 C11

An imaginary number is the product of a real number and √−1. A C implementation may support imaginary types, and you can test for them with:

#if __STDC_VERSION__ >= 199901L && !defined __STDC_NO_COMPLEX__
#include <complex.h>
#ifdef imaginary
/* Imaginary types supported */
#endif
#endif

Also note that, if __STDC_IEC_559_COMPLEX__ is defined, imaginary types must also be available.

Imaginary types are identified by the type specifier _Imaginary:

If imaginary types are supported, the header <complex.h> defines the following:

#define imaginary _Imaginary

…allowing the use of the following names:

The macro _Imaginary_I is defined to be a constant expression of type float imaginary with the value √−1. An imaginary constant (or a complex constant with an imaginary value) is created just by multiplying a real constant by _Imaginary:

float imaginary var = _Imaginary * 4.0;

It's also possible to use I, which might yield a complex constant, but with a zero real part, so an imaginary type can still represent it:

float imaginary var = I * 4.0;

That's my understanding of Annex G, which says There are three imaginary types… and An implementation that defines __STDC_IEC_559_COMPLEX__ shall conform to the specifications in this annex.

The sum of an imaginary number plus a real number is a complex number. Complex numbers can be represented by complex types, and they can represent all real values of a floating-point type, as well as all imaginary values of an imaginary type.


CHaR
Sitemap Supported
Site format updated 2024-06-05T22:37:07.391+0000
Data updated 1970-01-01T00:00:00.000+0000
Page updated 2023-10-04T20:24:03.213+0000