public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* What is -3.I (as opposed to 0-3.I) supposed evaluate to?
@ 2009-06-08 20:12 Kaveh R. GHAZI
  2009-06-08 20:33 ` Joseph S. Myers
  0 siblings, 1 reply; 6+ messages in thread
From: Kaveh R. GHAZI @ 2009-06-08 20:12 UTC (permalink / raw)
  To: gcc

If I write a complex double constant -3.I (as opposed to 0-3.I), what is
it supposed to evaluate to?  This program:

  #include <stdio.h>

  int main(void)
  {
    const __complex double C1 = (-3.I);
    const __complex double C2 = (0-3.I);

    printf ("%f %f\n", __real__ C1, __imag__ (C1));
    printf ("%f %f\n", __real__ C2, __imag__ (C2));

    return 0;
  }

when compiled with gcc-4.1.2 (and mainline) yields:

	-0.000000 -3.000000
	0.000000 -3.000000

Note the sign difference in the real part.

When I compile it with g++-4.1.2, I get:

	compl.c: In function 'int main()':
	compl.c:5: error: wrong type argument to unary minus

Is this supposed to happen or is it a bug in complex number parsing?
(Sorry if this is a gcc-help question.)

		Thanks,
		--Kaveh

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

end of thread, other threads:[~2009-06-09 15:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-08 20:12 What is -3.I (as opposed to 0-3.I) supposed evaluate to? Kaveh R. GHAZI
2009-06-08 20:33 ` Joseph S. Myers
2009-06-09  2:08   ` Kaveh R. Ghazi
2009-06-09 11:22     ` Joseph S. Myers
2009-06-09 15:26       ` Kaveh R. Ghazi
2009-06-09 15:33         ` Richard Guenther

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).