On Wed, Oct 12, 2005 at 10:06:41PM +0000, Joseph S. Myers wrote:
> On Wed, 12 Oct 2005, Steve Kargl wrote:
>
> > On Wed, Oct 12, 2005 at 01:24:41PM -0700, Richard Henderson wrote:
> > > On Wed, Oct 12, 2005 at 10:49:44AM -0700, Steve Kargl wrote:
> > > > How does one set z = 0 - I 0 in a portable manner with gcc?
> > >
> > > z = conj(0);
> > >
> >
> > I came to your solution after posting my question.
> > Unfortunately, the point of my original question
> > was missed. gcc is not following Annex G in n1124.pdf.
> > In particular, see G.5.1 Multiplicative operators.
>
> You don't say which paragraph of G.5.1 you are thinking of - paragraph 2
> is of course irrelevant (GCC doesn't implement _Imaginary and the
> imaginary type specifications in that informative annex are in direct
> conflict with the normative parts of the standard and of doubtful value to
> implement) while GCC versions before 4.0 don't make any attempt to
> implement the algorithm of paragraph 6 (which itself has been criticised,
> and only gets used by 4.x with -std=c99).
>From page 468, 5.2.1 (2):
If the operands are not both complex, then the result and
floating-point exception behavior of the * operator is defined
by the usual mathematical formula:
* | u iv u + iv
-------------------------------------------------------------------
x | xu i(xv) (xu) + i (xv)
iy | i(yu) -yv (-yv) + i (yu)
x + iy | (xu) + i(yu) (-yv) + i(xv)
u = copysign(0,-1);
z = I * u;
Either we have line 2 column 1 or line 3 column 1.
z = (i y) * u or (x + i y) * u
= i (yu) or (xu) + i (yu)
= i (1)*(-0) or (0)(-0) + i(1)(-0)
= i (-0) or ? + i (-0)
with ? in a state via F.8.2:
0 * x -> 0.0 The expression 0 * x and 0.0 are not equivalent if
x is a NaN, infinite, or -0.
--
Steve