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/13 Message-ID: <69hce6$8je@sjx-ixn6.ix.netcom.com>#1/1 X-Deja-AN: 315744516 References: <884291935.1575288842@dejanews.com> <694nm1$74c$1@news2.xs4all.nl><884364975.2133262340@dejanews.com> <695t9e$kft$1@agate.berkeley.edu><884411893.151322629@dejanews.com><884563899.2019688456@dejanews.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.3 Organization: Netcom X-NETCOM-Date: Tue Jan 13 7:46:14 PM PST 1998 Newsgroups: comp.os.linux.alpha,comp.arch Craig Burley wrote in message ... >As should be clear by now, thanks to Robert Harley's post, not >only was I right, but the reality is that the reason you see >faster Pentium performance is that you don't mind getting wrong >answers. The Pentium answers look wrong only if the ideal input to the FCOS instruction is k*2**n, where k & n are integers and |k| < 2**53. The alpha answers could be generated possibly by an algorithm that normalizes the (unbiased) exponent to 0 (or perhaps less) if it is initially greater than this, calculates the cosine of the resulting normalized number, then uses angle doubling (cos(2**(n+1)*theta) = 2*cos(2**n*theta)-1) to make up for the exponent modification in the first step. As R. Harley points out, such an approach can give you accurate results for numbers of the form k*2**n, but you pay big time for this 'accuracy' even when your input isn't of this form. Perhaps the C standard requires this, though... It seems like it wouldn't be a bad idea to switch to an approach that reduced the input modulo pi when the exponent gets big enough; if the user required exact results for numbers of the form k*2**n, she could use trig identities in her program instead of burdening the rest of the library users with her otherwise unwarranted overhead. Of course if the input is > 2**53, in absolute value a reasonable output would be a NaN.