From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 107079,183ebe04e93f0506 X-Google-Attributes: gid107079,public X-Google-Thread: 103376,183ebe04e93f0506 X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: fixed point vs floating point Date: 1997/11/23 Message-ID: #1/1 X-Deja-AN: 291769792 Distribution: inet References: <65846t$4vq$1@gonzo.sun3.iaf.nl> Organization: Estormza Software Newsgroups: comp.lang.ada,sci.math.num-analysis Date: 1997-11-23T00:00:00+00:00 List-Id: In article <65846t$4vq$1@gonzo.sun3.iaf.nl>, Geert Bosch wrote: >Maybe your second questions answers the first. It is really useless to >try hard to calculate a sinus using integer arithmetic when you have a >perfectly fine and very fast, well tested floating-point unit in your >computer that can calculate the sinus with a delta smaller than >0.000000000000001 probably. >Converting a fixed point value to fpt, issue the sinus instruction >and convert it back is much faster than even thinking about doing it in >fixed point. ;-) Sherman, Peabody: I think it's time for us to step into the way-back machine. Remember that thread a few months back about floating point comparison? As Robert reminded us, you have to know what you're doing when you use floating point arithmetic. I was trying to avoid floating point types, because I'm not a numerical analyst, and don't want to just *hope* my floating point calculations produce a correct result. I want to *know* they're correct. My error analysis is simpler if use a fixed point type, right? If my abstraction calls for a real type having an absolute error and not a relative error, then clearly a fixed point type is called for, even if it's less efficient, right? Isn't it always true that we should code for correctness first, by using a type that directly models the abstraction, and then optimize only if necessary? Are you making an exception to this rule for fixed point types? You seem to be suggesting - in the name of efficiency - that we convert a fixed point number into a floating point, calculate the sine, and then convert the result back into fixed point. OK, fair enough, but what is the accuracy of the result? Isn't this exactly the kind of thing Robert was warning us about? How much precision does one require for the floating point type? And you're sure that the conversion process doesn't add more expense than just calculating the sine directly in fixed point? Tell me, Geert, why do we even have fixed point in the language at all, if it's too inefficient to use? All my Ada books tell me to use a fixed point type when my abstraction has absolute error. But I don't remember them saying, Do not use fixed point types because they're too inefficient. None say "you shouldn't even think about calculating a sine using fixed point." Under what circumstances do you use fixed point? Or are you saying never to use fixed point? I still would like someone to give me a reason - unrelated to efficiency - why you'd model a heading (or any other kind of angle) using a floating point type instead of a fixed point type. -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271