From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 102b75,7b37ae94a49a9eec X-Google-Attributes: gid102b75,public X-Google-Thread: 111c93,b79a29863eb727e7 X-Google-Attributes: gid111c93,public From: "James Van Buskirk" Subject: Re: gcc vs Dec Unix c Date: 1998/01/14 Message-ID: <69jqsk$t7k@dfw-ixnews7.ix.netcom.com>#1/1 X-Deja-AN: 316042863 References: <884291935.1575288842@dejanews.com> <884563899.2019688456@dejanews.com> <69hce6$8je@sjx-ixn6.ix.netcom.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.3 Organization: Netcom X-NETCOM-Date: Wed Jan 14 8:05:08 PM CST 1998 Newsgroups: comp.os.linux.alpha,comp.arch brianh@bit3.com wrote in message ... >In article <69hce6$8je@sjx-ixn6.ix.netcom.com>, >James Van Buskirk wrote: >> > >>FCOS instruction is k*2**n, where k & n are integers and >>|k| < 2**53. > >Stupid question: can't all IEEE floating point numbers be treated as >being in this form? Or, actually, with a little modification- if >the floating point number is m * 2**e, where 1 <= m < 2, and e is a >small integer, then couldn't you set k = m * 2**p and n = e-p, where >p is the precision of the floating point number (53 in the case of IEEE >doubles)? > >Or am I missing something obvious? Yes, all IEEE 754 double precision floating point numbers are in this form, but the point that I was trying to make (with the word 'ideal') was that not all numbers are of this form. Thus when your program calls for cos(x), the number x cannot be represented, in general, with perfect accuracy as an IEEE 754 double precision floating point number. For example, when your program calculates cos(1234567890.d0), the number you really want the cosine of could be anywhere from 1234567890-2^(-23) to 1234567890+2^(-23). In an ordinary program one should not, in my opinion, be dismayed if the cosine of any number in this range is returned. In fact Intel uses an internal 66-bit value of pi when it reduces to the range of validity for its minmax polynomial, so the range goes down to 1234567890-2^(-36) to 1234567890+2^(-36), and the value returned e.g. by LF90 corresponds to an input in that range. Digital's alpha compilers (e.g. DVF90 Pro) seem to interpret the input as exact and produce the double precision cosine of the 'exact' input to double precision accuracy (confirmed by comparing 100 digit Mathematica output.) In many contexts, the extra accuracy is illusory as the input in the above case would have to be known to 30 bits more accuracy for the last bit of the output to have any meaning. Curiously, DVF90 Pro gets the same results with both the 'fast' and the 'accurate' math libraries, although the 'accurate' library takes about twice as long to get there. In cases where the IEEE 754 representation of the input is exact, Digital is doing much better than Intel here but I think that those cases are relatively rare.