home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.sun.misc
- Path: sparky!uunet!spool.mu.edu!agate!ames!sun-barr!sh.wide!wnoc-tyo-news!news.u-tokyo.ac.jp!yayoi!jari
- From: jari@ai.rcast.u-tokyo.ac.jp (Jari Vaario)
- Subject: Sun's math library bug?
- Message-ID: <JARI.93Jan28215100@ebi.ai.rcast.u-tokyo.ac.jp>
- Lines: 65
- Sender: news@cc.u-tokyo.ac.jp (USENET News System)
- Nntp-Posting-Host: ebi.ai.rcast.u-tokyo.ac.jp
- Organization: RCAST, Univ. of Tokyo, Japan
- Distribution: comp.sys.sun.misc
- Date: Thu, 28 Jan 1993 12:49:47 GMT
- Lines: 65
-
-
- The 'cospi' and 'sincospi' functions returns cos value 1 for 180.0 angle.
- It should be -1 as the 'cos' function returns correctly!
-
- Am I missing something or is this a bug? Please, reply by e-mail.
-
- Thank you,
- :-) Jari Vaario
-
- ------------------ Cut here for a test program ---------------
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h> /* @(#)math.h 1.30 89/07/20 SMI */
-
- main() {
- int deg;
- double sinpid, cospid;
- for( deg = 0; deg <= 360; deg+=90 ) {
- sincospi((double)deg/180.0, &sinpid, &cospid);
- printf("deg=%d, sinpi=%g, cospi=%g\n",
- deg, sinpid, cospid);
- printf("deg=%d, sinpi=%g, cospi=%g\n",
- deg, sinpi((double)deg/180.0), cospi((double)deg/180.0));
- printf("deg=%d, sin=%g, cos=%g\n\n",
- deg, sin(M_PI*(double)deg/180.0), cos(M_PI*(double)deg/180.0));
- }
- }
- --------------- Compiled by the command -----------------------
-
- cc -o cosTest cosTest.c -lm
-
- --------------- This is the output -----------------------------
- deg=0, sinpi=0, cospi=1
- deg=0, sinpi=0, cospi=1
- deg=0, sin=0, cos=1
-
- deg=90, sinpi=1, cospi=0
- deg=90, sinpi=1, cospi=0
- deg=90, sin=1, cos=6.12303e-17
-
- deg=180, sinpi=0, cospi=1 << HERE SHOULD BE -1!
- deg=180, sinpi=0, cospi=1 << HERE SHOULD BE -1!
- deg=180, sin=1.22461e-16, cos=-1 << THIS IS CORRECT!
-
- deg=270, sinpi=-1, cospi=-0
- deg=270, sinpi=-1, cospi=-0
- deg=270, sin=-1, cos=-1.83691e-16
-
- deg=360, sinpi=0, cospi=1
- deg=360, sinpi=0, cospi=1
- deg=360, sin=-2.44921e-16, cos=1
-
- ---------------------- This is our OS ------------------------
- cat /etc/motd
- SunOS Release 4.1.2-JLE1.1.2 (GENERIC) #1: Mon Dec 2 19:12:34 JST 1991
-
- --
- ___________________________________________________________________________
- |~~~\ University of Tokyo | Jari Vaario, jari@ai.rcast.u-tokyo.ac.jp
- | | /~~~\ /\ /~~~\~~~T~~~ | Research Center for
- |___/| / \ \___ | | Advanced Science and Technology/OHlab.
- | \ | /~~~~\ \ | | Komaba 4-6-1, Meguro-ku, 153 Tokyo, Japan
- | \ \___// \\___/ | | tel. +81-3-3481-4486/fax. +81-3-3481-4585
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-