This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: How do I initialize a __complex128 variable?
- From: FX <fxcoudert at gmail dot com>
- To: Bill L <biloucks at gmail dot com>
- Cc: GCC Development <gcc at gcc dot gnu dot org>
- Date: Thu, 21 Jul 2016 15:15:45 +0200
- Subject: Re: How do I initialize a __complex128 variable?
- Authentication-results: sourceware.org; auth=none
- References: <def2df92-8532-f966-743e-02f1f6212a5b@gmail.com>
> 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)