www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/08/15/06:04:49

Date: Mon, 15 Aug 1994 10:14:31 +0200
From: mwijz AT phys DOT uva DOT nl (Maud Wijzenbeek)
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Complex numbers

Complex multiplication with version 1.12 give strange results:

***********************************************************
/* Test of GNU-C: complex number multiplication. */

# include <stdio.h>

__complex__ float a;

void comprint(__complex__ p, __complex__ q)
{
   __complex__ float r;

   r = p * q;
   printf("(%0.2f+%0.2fi) * ", __real__ p, __imag__ p);
   printf("(%0.2f+%0.2fi) = ", __real__ q, __imag__ q);
   printf("(%0.2f+%0.2fi)\n",  __real__ r, __imag__ r);
}

main()
{
   a = 1.0 + 0.0fi;

   comprint(a,  1.0 +  0.0fi);
   comprint(a,  0.0 +  1.0fi);
   comprint(a, -1.0 +  0.0fi);
   comprint(a,  0.0 + -1.0fi);

   return 0;
}
***********************************************************

Gives

go32 version 1.12 Copyright (C) 1994 DJ Delorie
(1.00+0.00i) * (1.00+0.00i) = (1.00+1.00i)
(1.00+0.00i) * (0.00+1.00i) = (0.00+0.00i)
(1.00+0.00i) * (-1.00+0.00i) = (-1.00+-1.00i)
(1.00+0.00i) * (0.00+-1.00i) = (0.00+0.00i)

By the way, it takes my 486 with 8 Mb of memory (639 K free memory),
Dr.Dos 6.0 and Qemm about 50 sec. to compile this program. Is that
normal?

Maurits Wijzenbeek
mwijz AT phys DOT uva DOT nl

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019