On Monday 02 October 2006 20:53, Gabriel Dos Reis wrote: [...] > > | the result of the "same" multiplication considered as complex * > | complex (vs complex * real) has a different sign for the zero > | imaginary component. > > Thanks for the example. I'm not sure this was anticipated by the C++ > specification. I suspect I have to raise this on LWG. >
Note that this problem also makes the two common complex initialisation strategies behave differently: in the second case below the sign of the imaginary part of z has disappeared: #include <complex.h> #include <stdio.h> int main() { double complex z; double x=1.0; double y=-0.0; __real__ z = x; __imag__ z = y; printf("%e %e\n", creal(z), cimag(z)); z = x + y*I; printf("%e %e\n", creal(z), cimag(z)); return 0; } [EMAIL PROTECTED]:../bessel $ gcc t16.c -O0 && ./a.out 1.000000e+00 -0.000000e+00 1.000000e+00 0.000000e+00 Another effect is that: when z==(1,-0.0), we get: creal(z) + cimag(z)*I = (1, +0.0). Since 0==-0, formally this is not in conflict with footnote 166 on page 179 of ISO/IEC 9899:TC2, but well ... the standard is not too friendly for users of complex functions with branch cuts. Regards, Jan.