This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How do I initialize a __complex128 variable?


> How do I initialize a __complex128 variable?  I found no documentation.

$ cat a.c
#include <quadmath.h>
#include <stdlib.h>
#include <stdio.h>

int main(void)
{
  char s1[50], s2[50];
  const __complex128 z = -0.3Q + 0.1Qj;
  quadmath_snprintf (s1, sizeof(s1), "%20Qe", __real__ z);
  quadmath_snprintf (s2, sizeof(s2), "%20Qe", __imag__ z);
  printf ("(%s,%s)\n", s1, s2);
  return 0;
}

$ gcc a.c -lquadmath -W -Wall && ./a.out
(       -3.000000e-01,        1.000000e-01)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]