www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2005/05/16/11:52:22

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
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 <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
Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable

<HTML><FONT FACE=3Darial,helvetica><HTML><FONT  SIZE=3D3 PTSIZE=3D12 FAMILY=
=3D"SERIF" FACE=3D"Georgia" LANG=3D"0">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.<BR>
<BR>
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).<BR>
<BR>
Am I having a problem with gcc 3.4.3?<BR>
<BR>
<BR>
KB Williams<BR>
=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<BR>
HUGE_VAL =3D Inf<BR>
Setting complex double XX =3D HUGE_VAL + HUGE_VAL * I<BR>
Setting double AA =3D creal(XX); AA =3D NaN<BR>
<BR>
#include "complex.h"<BR>
#include &lt;math.h&gt;<BR>
#include &lt;stdio.h&gt;<BR>
#include &lt;stdlib.h&gt;<BR>
int main(void)<BR>
{<BR>
=A0=A0=A0 double=A0 AA;<BR>
=A0=A0=A0 complex double XX;<BR>
<BR>
=A0=A0=A0 printf("HUGE_VAL =3D %lg\n", HUGE_VAL);<BR>
=A0=A0=A0 printf("Setting complex double XX =3D HUGE_VAL + HUGE_VAL * I\n");=
<BR>
=A0=A0=A0 XX =3D HUGE_VAL + HUGE_VAL * I;<BR>
=A0=A0=A0 printf("Setting double AA =3D creal(XX); AA =3D %lg\n", AA =3D cre=
al(XX));<BR>
exit(0);<BR>
}<BR>
<BR>
#include &lt;complex.h&gt;<BR>
<BR>
double<BR>
creal(double complex z)<BR>
{<BR>
=A0=A0=A0 return __real__ z;<BR>
}<BR>
</FONT><FONT  COLOR=3D"#000000" BACK=3D"#ffffff" style=3D"BACKGROUND-COLOR:=20=
#ffffff" SIZE=3D2 PTSIZE=3D10 FAMILY=3D"SANSSERIF" FACE=3D"Arial" LANG=3D"0"=
><BR>
</FONT></HTML>
--part1_81.27bd980d.2fba1936_boundary--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019