Namespaces
Variants

_Complex_I

From cppreference.net
헤더 파일에 정의됨 <complex.h>
#define _Complex_I /* 지정되지 않음 */
(C99 이후)

_Complex_I 매크로는 허수 단위의 값을 갖는 const float _Complex 타입의 값으로 확장됩니다.

목차

참고 사항

이 매크로는 I 를 사용할 수 없을 때, 예를 들어 애플리케이션에 의해 정의가 해제된 경우에 사용할 수 있습니다.

_Imaginary_I CMPLX 와 달리, 이 매크로를 사용하여 복소수를 구성할 경우 허수부의 영(zero) 부호가 손실될 수 있습니다.

예제

#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));
}

가능한 출력:

1.0 + 2.0 * _Complex_I = 1.0+2.0i
0.0 + -0.0 * _Complex_I = 0.0+0.0i

참고문헌

  • C23 표준 (ISO/IEC 9899:2024):
  • 7.3.1/4 _Complex_I (p: TBD)
  • C17 표준 (ISO/IEC 9899:2018):
  • 7.3.1/4 _Complex_I (p: 136)
  • C11 표준 (ISO/IEC 9899:2011):
  • 7.3.1/4 _Complex_I (p: 188)
  • C99 표준 (ISO/IEC 9899:1999):
  • 7.3.1/2 _Complex_I (p: 170)

참고 항목

허수 단위 상수 i
(매크로 상수)
(C99)
복소수 또는 허수 단위 상수 i
(매크로 상수)