Date: Sun, 4 Dec 94 03:36:16 +0100 From: sl051ma AT unidui DOT uni-duisburg DOT de (Michael Mauch) To: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Bug in __complex__ ? Diskussion-In: /UNIDUI/DJGPP Hi! Maybe this is just a silly bug of mine, but _where_ is it? The following program: -------------- char* cf2a(__complex__ float z) { static char s[80]; float x=__real__(z), y=__imag__(z); if(x!=0.0) { sprintf(s,"%.3g",x); if(y>0.0) strcat(s,"+"); } else *s='\0'; if(y!=0.0) sprintf(s+strlen(s),"%.3gi",y); return s; } main() { __complex__ float a=2.0f+3.0fi, b=1.0f+0.0fi; printf("a=%s\n",cf2a(a)); printf("b=%s\n",cf2a(b)); printf("a+b=%s\n",cf2a(a+b)); printf("a*b=%s\n",cf2a(a * b)); } -------------- turns out to show: a=2+3i b=1 a+b=3+3i a*b=2+2i So what went wrong with this program? a*b=2+2i ??? I would appreciate gcc handle complex numbers, but this isn't the right way, is it? I'm using 1.12m2. BTW: is there a better way (sort of a formatter) to printf() a complex numb