[comp.sys.mac.programmer] complex.h in MPW C 3.1

jess@gn.ecn.purdue.edu (Jess M Holle) (06/10/91)

In an attempt to test the feasibility of adding complex number handling to
a program I'm working on, I attempted to use the interfaces declared in MPW
C 3.1's complex.h file and link to Complex.o. At first, since this was but
a short test program, which I was compiling as an MPW tool, I did an automated
"create build commands" and set the "tool" option. I then attempted a build.
The build gave me errors of something like "cdiv invalid entry." I was
thoroughly confused, until I checked the build commands. The portion of the
link command referring to Complex.o was commented out! I removed the comment
# and started the build again. This time the build went fine, but when testing
a csqrt() call, I discovered that the results were TOTALLY erroneous (the
real portion of the result was fine, but the imaginary part was off by several
orders of magnitude) when checked against my HP48SX. Also, 4 / 2 yielded 
2 + 1.0e-4928 (or something close to that) when 4 and 2 were both stored as 
complex numbers, and cdiv was used to do the division.

These results were the same with both the "default" and "-mc68881" options.

What is the deal with Complex.o??? Does Apple know that it doesn't work, so
they commented it out of the build? If so, why didn't they fix this before
releasing 3.1. Doesn't MPW C++ use this same library? Does this mean that
Apple's C++ doesn't work with complex numbers????

Any answers would be greatly appreciated. Any further general information 
on Apple's complex number implementation under MPW C would be appreciated 
as well.

Jess Holle