Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      _Imaginary_I

      From cppreference.com
      <c‎ |numeric‎ |complex
       
       
       
      Complex number arithmetic
      Types and the imaginary constant
      (C99)
      (C99)    
      (C11)
      _Imaginary_I
      (C99)
      (C99)
      Manipulation
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
      Power and exponential functions
      (C99)
      (C99)
      (C99)
      (C99)
      Trigonometric functions
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
      Hyperbolic functions
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
       
      Defined in header<complex.h>
      #define _Imaginary_I /* unspecified */
      (since C99)

      The_Imaginary_I macro expands to a value of typeconstfloat _Imaginary with the value of the imaginary unit.

      As with any pure imaginary number support in C, this macro is only defined if the imaginary numbers are supported.

      A compiler that defines__STDC_IEC_559_COMPLEX__ is not required to support imaginary numbers. POSIX recommends checking if the macro_Imaginary_I is defined to identify imaginary number support.

      (since C99)
      (until C11)

      Imaginary numbers are supported if__STDC_IEC_559_COMPLEX__ is defined.

      (since C11)

      Contents

      [edit]Notes

      This macro allows for the precise way to assemble a complex number from its real and imaginary components, e.g. with(doublecomplex)((double)x+ _Imaginary_I*(double)y). This pattern was standardized in C11 as the macroCMPLX. Note that if_Complex_I is used instead, this expression is allowed to convert negative zero to positive zero in the imaginary position.

      [edit]Example

      Run this code
      #include <stdio.h>#include <complex.h>#include <math.h> int main(void){doublecomplex z1=0.0+ INFINITY* _Imaginary_I;printf("z1 = %.1f%+.1fi\n",creal(z1),cimag(z1)); doublecomplex z2=0.0+ INFINITY*_Complex_I;printf("z2 = %.1f%+.1fi\n",creal(z2),cimag(z2));}

      Output:

      z1 = 0.0+Infi z2 = NaN+Infi

      [edit]References

      • C11 standard (ISO/IEC 9899:2011):
      • 7.3.1/5 _Imaginary_I (p: 188)
      • G.6/1 _Imaginary_I (p: 537)
      • C99 standard (ISO/IEC 9899:1999):
      • 7.3.1/3 _Imaginary_I (p: 170)
      • G.6/1 _Imaginary_I (p: 472)

      [edit]See also

      the complex unit constant i
      (macro constant)[edit]
      (C99)
      the complex or imaginary unit constant i
      (macro constant)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/numeric/complex/Imaginary_I&oldid=109400"

      [8]ページ先頭

      ©2009-2025 Movatter.jp