public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Kaveh R. GHAZI" <ghazi@caip.rutgers.edu>
To: gcc@gcc.gnu.org
Subject: What is -3.I (as opposed to 0-3.I) supposed evaluate to?
Date: Mon, 08 Jun 2009 20:12:00 -0000	[thread overview]
Message-ID: <Pine.GSO.4.58.0906081603270.4648@caipclassic.rutgers.edu> (raw)

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

             reply	other threads:[~2009-06-08 20:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-08 20:12 Kaveh R. GHAZI [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.GSO.4.58.0906081603270.4648@caipclassic.rutgers.edu \
    --to=ghazi@caip.rutgers.edu \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).