From: "Shaggs" Newsgroups: comp.os.msdos.djgpp Subject: Re: cos(90 * (PI / 180) = 6.12... (now has an idea of what happened Date: Mon, 31 May 1999 17:01:01 -0700 Organization: Posted via RemarQ Communities, Inc. Lines: 61 Message-ID: <928195118.463.39@news.remarQ.com> References: <7ii9di$sng$1 AT remarQ DOT com> <374DBEE8 DOT E73D32ED AT cartsys DOT com> NNTP-Posting-Host: 208.145.132.112 NNTP-Posting-Date: Mon, 31 May 1999 23:58:38 GMT X-Trace: 928195118.463.39 K8TBLZBRT8470D091C qube-02.us-ca.remarq.com X-Complaints-To: newsabuse AT remarQ DOT com X-Newsreader: Microsoft Outlook Express 4.72.3612.1700 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3612.1700 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com All my values seem perfectly normal for sine and cosine, but on degrees that are even with an axis, such as 90,18,270, etc i get some way off number, my proccessor is a p166, no mmx, purchased when 200 was the highest, and MMX was really new Nate Eldredge wrote in message <374DBEE8 DOT E73D32ED AT cartsys DOT com>... >Shaggs wrote: >> >> cos(90 * (PI / 180) = 6.12... could this be the result of the pentium flaw, >> as i have the sin and cos stored in arrays of double > >Hasn't this come up before? > >Look at the complete result, and think about what exponential notation >means. Then compare it with the value of DBL_EPSILON, which is the >approximate precision of double. Is your result within DBL_EPSILON of >the expected 0? > >I don't think the Pentium FDIV bug is a likely suspect here. Though it >did exist, I've never heard that it was so gross as to give answers off >by 6 in the most significant digit. Have you even got an old enough >Pentium that could have it? > >If you really want to know, this code should check for it. It's >borrowed from the Linux source. > >#include > >static double x = 4195835.0; >static double y = 3145727.0; > >int has_fdiv_bug(void) >{ > int result; > __asm__("fninit\n\t" > "fldl %1\n\t" > "fdivl %2\n\t" > "fmull %2\n\t" > "fldl %1\n\t" > "fsubp %%st,%%st(1)\n\t" > "fistpl %0\n\t" > "fwait\n\t" > "fninit" > : "=m" (result) > : "m" (x), "m" (y)); > return result; >} > >int main(void) >{ > printf("FDIV bug %s\n", has_fdiv_bug() ? "found" : "not found"); > return 0; >} > >-- > >Nate Eldredge >nate AT cartsys DOT com