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: 103376,183ebe04e93f0506 X-Google-Attributes: gid103376,public X-Google-Thread: 107079,183ebe04e93f0506 X-Google-Attributes: gid107079,public From: Geert Bosch Subject: Re: fixed point vs floating point Date: 1997/11/24 Message-ID: <65c4vg$7ak$1@gonzo.sun3.iaf.nl>#1/1 X-Deja-AN: 292243636 References: <65846t$4vq$1@gonzo.sun3.iaf.nl> Distribution: inet Organization: La Calandre Infortunee Newsgroups: comp.lang.ada,sci.math.num-analysis Date: 1997-11-24T00:00:00+00:00 List-Id: Matthew Heaney wrote: ``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? '' The fixed point type is the abstraction that you do calculations with when you are calculating with currencies for example. The heading of a ship is of course a real value. So any difference between this real value and the calculated one (whether fixed or float) is error for you. When converting a real value between 0.0 and 360.0 to a value in radians and then taking the sine using floating pt you will have a result that has a certain relative error. Since you also know that the result interval is in -1.0 .. 1.0, you have a result with a known absolute precision. On typical hardware this absolute error will be much smaller than 1.0E-12. Regards, Geert Disclaimer: I'm not a numerical analyst!