Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!apple!uokmax!servalan!epmooch!ben From: ben@epmooch.UUCP (Rev. Ben A. Mesander) Newsgroups: comp.sys.amiga.programmer Subject: Re: Switching between integer and floating point Message-ID: Date: 23 Apr 91 21:09:39 GMT References: <1991Apr24.041205.1588@netcom.COM> Lines: 36 >In article <1991Apr24.041205.1588@netcom.COM> rodent@netcom.COM (Ben Discoe) writes: > > I've been working on a 3D object viewer intended for PD release, with >source, as soon as it's stable. My problem is this: when the project was >started, I only had a 1000 to work on, so I wrote all the math using >two kinds of fixed-point integer math (one kind for angles, another for >coordinates). > Now I (and many people who may want the code) are on accelerated >systems with 6888x's, so I'd like to include a compile-time flag to >compile with floating-point math instead of the integers. I'm sure many >other people have faced this same problem: how do you keep one source >with two different kinds of math involved? > There are three options I can think of, and none are appealing. > > 1. use a lot of #defines: > >#if INTEGER > #define mult(a, b) ((a*b)>>8) >#else > #define mult(a, b) (a*b) >#endif Or, you could use pointers to functions, and allow the same object module to be used on machines that have a 6888x and those that don't. I don't find either that solution or the one your propose above "ugly", although I guess you do... > This makes code very ugly and hard to understand/debug. I'm not sure how you mean, Ben.. -- | ben@epmooch.UUCP (Ben Mesander) | "Cash is more important than | | ben%servalan.UUCP@uokmax.ecn.uoknor.edu | your mother." - Al Shugart, | | !chinet!uokmax!servalan!epmooch!ben | CEO, Seagate Technologies |