X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f From: Kbwms AT aol DOT com Message-ID: <81.27bd980d.2fba1936@aol.com> Date: Mon, 16 May 2005 11:41:42 EDT Subject: Problem with Complex To: djgpp-workers AT delorie DOT com MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="part1_81.27bd980d.2fba1936_boundary" X-Mailer: 8.0 for Windows sub 6033 Reply-To: djgpp-workers AT delorie DOT com --part1_81.27bd980d.2fba1936_boundary Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable I'm having trouble understanding a problem when using complex stuff. =A0 Whe= n I=20 have a complex quantity set to HUGE_VAL + HUGE_VAL * I and I try to take the= =20 real part, the result is NaN. Recall, HUGE_VAL =3D Inf. Below is the output from a tiny program that illustrates the problem. =A0 Th= e=20 tiny program is included followed by function creal(complex double). Am I having a problem with gcc 3.4.3? KB Williams =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D HUGE_VAL =3D Inf Setting complex double XX =3D HUGE_VAL + HUGE_VAL * I Setting double AA =3D creal(XX); AA =3D NaN #include "complex.h" #include #include #include int main(void) { =A0=A0=A0 double=A0 AA; =A0=A0=A0 complex double XX; =A0=A0=A0 printf("HUGE_VAL =3D %lg\n", HUGE_VAL); =A0=A0=A0 printf("Setting complex double XX =3D HUGE_VAL + HUGE_VAL * I\n"); =A0=A0=A0 XX =3D HUGE_VAL + HUGE_VAL * I; =A0=A0=A0 printf("Setting double AA =3D creal(XX); AA =3D %lg\n", AA =3D cre= al(XX)); exit(0); } #include double creal(double complex z) { =A0=A0=A0 return __real__ z; } --part1_81.27bd980d.2fba1936_boundary Content-Type: text/html; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable I'm having trouble understanding a pr= oblem when using complex stuff. =A0 When I have a complex quantity set to HU= GE_VAL + HUGE_VAL * I and I try to take the real part, the result is NaN.&nb= sp; Recall, HUGE_VAL =3D Inf.

Below is the output from a tiny program that illustrates the problem. =A0 Th= e tiny program is included followed by function creal(complex double).

Am I having a problem with gcc 3.4.3?


KB Williams
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
HUGE_VAL =3D Inf
Setting complex double XX =3D HUGE_VAL + HUGE_VAL * I
Setting double AA =3D creal(XX); AA =3D NaN

#include "complex.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
=A0=A0=A0 double=A0 AA;
=A0=A0=A0 complex double XX;

=A0=A0=A0 printf("HUGE_VAL =3D %lg\n", HUGE_VAL);
=A0=A0=A0 printf("Setting complex double XX =3D HUGE_VAL + HUGE_VAL * I\n");=
=A0=A0=A0 XX =3D HUGE_VAL + HUGE_VAL * I;
=A0=A0=A0 printf("Setting double AA =3D creal(XX); AA =3D %lg\n", AA =3D cre= al(XX));
exit(0);
}

#include <complex.h>

double
creal(double complex z)
{
=A0=A0=A0 return __real__ z;
}

--part1_81.27bd980d.2fba1936_boundary--