From: Creed <110370 DOT 3162 AT CompuServe DOT COM> Newsgroups: comp.os.msdos.djgpp Subject: Trig Bug? Date: 23 Jan 2000 04:12:41 GMT Organization: sometimes Lines: 47 Message-ID: <86dv3p$p24$1@ssauraab-i-1.production.compuserve.com> NNTP-Posting-Host: mhako.production.compuserve.com X-Trace: ssauraab-i-1.production.compuserve.com 948600761 25668 149.174.242.227 (23 Jan 2000 04:12:41 GMT) X-Complaints-To: newsmaster AT compuserve DOT com NNTP-Posting-Date: 23 Jan 2000 04:12:41 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Dear djgpp people: I'm a newbie who has found what sure looks like a bug. The trig functions fail grossly at some angles, including some angles between 1.12 and 1.31 radians. When they do not fail grossly they are quite accurate. For example at an angle of 1.13 radians a test program finds to six decimal places: sin= 0.684014 cos = 0.878084 sin^2 + cos^2 = 1.238908 and tan= 0.935537 The correct answers are: sin = 0.904413 cos = 0.426660 sin^2 + cos^2 = 1.000000 and tan= 2.119750 I'm using djgpp version 2.8.1 and have djdev202, on a 486SX with no floating point processor, under Windows for Workgroups 3.11, in the DOS-box (MS-DOS 6.20). The computer is a Packard-Bell Pack-Mate 27 Plus running at 50MHz. I believe I am using libemu.a (I never downloaded that WEMU thing.) The test program I am using, named "testrig.c", is: #include #include int main(void) { double w=1.13; printf("w= %f, sin= %f, cos= %f ", w, sin(w), cos(w)); printf("1= %f, tan= %f \n", pow(sin(w),2)+pow(cos(w),2), tan(w)); exit(0); } I compile this test program like so: gcc -Wall testrig.c -lm It produces the output: w= 1.130000, sin= 0.684014, cos= 0.878084 1= 1.238908, tan= 0.935537 So, what do you think? Is this a bug in the floating point emulation or what? Chris