Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!ames!claris!apple!apple.com!shebanow From: shebanow@apple.com (Andrew Shebanow) Newsgroups: comp.sys.mac.programmer Subject: Re: Endless inSANEity... Message-ID: <2424@internal.Apple.COM> Date: 20 Jun 89 20:58:59 GMT References: <227700009@uxa.cso.uiuc.edu> Sender: usenet@Apple.COM Organization: Apple Computer, Inc. Lines: 58 In article <227700009@uxa.cso.uiuc.edu> cjr20670@uxa.cso.uiuc.edu writes: > So that's the first big problem, how do I put the 881 "double" in the > same struct? They're both called double, but one is 12 bytes and the other > is 10 bytes. I can't specify one without the other. Gggrrrrr. For LSC, I recommend that you use the "short double" type (64 bits) in your data structures instead of double. You probably don't need the extra precision, and this data type is the same whether you have an 881 or not. The only disadvantage is that SANE is slower on 64 bit operations than it is on 80 bit (96 for 881) operations, since it has to convert the operands to 80 bit before doing its calculations. You can get around this limitation by caching the extended versions of your numbers inside of complex calculations. As far as using 881 and non-881 libraries together goes, you are going to have a tough job. What I recommend is that you compile everything without the 881 option turned on, and that you isolate (and minimize) your floating point library calls. For each library call you want to use, write a wrapper function like this: extern Boolean haveFPU; typedef short double96[6]; double myLibraryCall(double a, double b) { double96 tmpA, tmpB, tmpRes; double res; if (haveFPU) { x80tox96(&a,tmpA); x80tox96(&b,tmpB); asm { /* * do the whole thing in assembler, using FPU instructions * Move tmpA and tmpB into FPU registers, store result in tmpRes */ }; x96tox80(tmpRes,&res); return res; } else return RealLibraryCall(a,b); } You will have to write the routines x80tox96 and x96tox80 yourself, but they aren't that tough - just bitshift things around (BTW, MPW 3.0 includes these routines). This whole solution is ugly, but it should work. Disclaimer: I've done this on a small scale in MPW 3.0, so I know it can be done, but I haven't tried it in LSC, so there may be some unexpected problems. Have fun, Andrew Shebanow MacDTS - Wanna See Something REALLY Scary? -