public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/19138] New: double complex / inf gives nan instead of 0
@ 2004-12-23 14:35 dmitri at unm dot edu
  2004-12-23 14:41 ` [Bug middle-end/19138] " pinskia at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: dmitri at unm dot edu @ 2004-12-23 14:35 UTC (permalink / raw)
  To: gcc-bugs

The following program gives "nan nan" output instead of expected "0 0"
#include <stdio.h>

_Complex double a, r;
double b = 1.0 / 0.0;

int
main (void)
{
  __real__ a = 1.0;
  __imag__ a = -1.0;
  r = a / b;
  printf ("%f %f\n", __real__ r, __imag__ r);
  return 0;
}


As alois.schloegl@tugraz.at pointed out
<<<<
Prof. W .Kahan mentions in his "Lecture Notes on the Status of IEEE
754" p.10
http://www.cs.berkeley.edu/~wkahan/ieee754status/IEEE754.PDF

"when (0+3i)/inf is turned naively into (0+3i)*(inf-i)/(inf^2+0^2) it
generates
a NaN instead of the expected 0."
>>>>

This may be of some relevance here.

-- 
           Summary: double complex / inf gives nan instead of 0
           Product: gcc
           Version: 3.2.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dmitri at unm dot edu
                CC: gcc-bugs at gcc dot gnu dot org,jakub at redhat dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19138


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2004-12-23 23:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-23 14:35 [Bug c/19138] New: double complex / inf gives nan instead of 0 dmitri at unm dot edu
2004-12-23 14:41 ` [Bug middle-end/19138] " pinskia at gcc dot gnu dot org
2004-12-23 14:43 ` dmitri at unm dot edu
2004-12-23 15:18 ` dmitri at unm dot edu
2004-12-23 15:50 ` joseph at codesourcery dot com
2004-12-23 17:14 ` bangerth at dealii dot org
2004-12-23 19:20 ` pcarlini at suse dot de
2004-12-23 23:06 ` bangerth at dealii dot org
2004-12-23 23:17 ` pcarlini at suse dot de
2004-12-23 23:19 ` bangerth at dealii dot org
2004-12-23 23:22 ` pcarlini at suse dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).