home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / sun / misc / 6577 < prev    next >
Encoding:
Text File  |  1993-01-28  |  2.6 KB  |  79 lines

  1. Newsgroups: comp.sys.sun.misc
  2. Path: sparky!uunet!spool.mu.edu!agate!ames!sun-barr!sh.wide!wnoc-tyo-news!news.u-tokyo.ac.jp!yayoi!jari
  3. From: jari@ai.rcast.u-tokyo.ac.jp (Jari Vaario)
  4. Subject: Sun's math library bug?
  5. Message-ID: <JARI.93Jan28215100@ebi.ai.rcast.u-tokyo.ac.jp>
  6. Lines: 65
  7. Sender: news@cc.u-tokyo.ac.jp (USENET News System)
  8. Nntp-Posting-Host: ebi.ai.rcast.u-tokyo.ac.jp
  9. Organization: RCAST, Univ. of Tokyo, Japan
  10. Distribution: comp.sys.sun.misc
  11. Date: Thu, 28 Jan 1993 12:49:47 GMT
  12. Lines: 65
  13.  
  14.  
  15. The 'cospi' and 'sincospi' functions returns cos value 1 for 180.0 angle.
  16. It should be -1 as the 'cos' function returns correctly!
  17.  
  18. Am I missing something or is this a bug? Please, reply by e-mail.
  19.  
  20. Thank you,
  21. :-) Jari Vaario
  22.  
  23. ------------------ Cut here for a test program ---------------
  24.  
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include <math.h> /*      @(#)math.h 1.30 89/07/20 SMI    */
  28.  
  29. main() {
  30.   int deg;
  31.   double sinpid, cospid;
  32.   for( deg = 0; deg <= 360; deg+=90 ) {
  33.     sincospi((double)deg/180.0, &sinpid, &cospid);
  34.     printf("deg=%d, sinpi=%g, cospi=%g\n",
  35.            deg, sinpid, cospid);
  36.     printf("deg=%d, sinpi=%g, cospi=%g\n",
  37.            deg, sinpi((double)deg/180.0), cospi((double)deg/180.0));
  38.     printf("deg=%d, sin=%g, cos=%g\n\n",
  39.            deg, sin(M_PI*(double)deg/180.0), cos(M_PI*(double)deg/180.0));
  40.   }
  41. }
  42. --------------- Compiled by the command -----------------------
  43.  
  44. cc -o cosTest cosTest.c -lm
  45.  
  46. --------------- This is the output -----------------------------
  47. deg=0, sinpi=0, cospi=1
  48. deg=0, sinpi=0, cospi=1
  49. deg=0, sin=0, cos=1
  50.  
  51. deg=90, sinpi=1, cospi=0
  52. deg=90, sinpi=1, cospi=0
  53. deg=90, sin=1, cos=6.12303e-17
  54.  
  55. deg=180, sinpi=0, cospi=1        << HERE SHOULD BE -1!
  56. deg=180, sinpi=0, cospi=1        << HERE SHOULD BE -1!
  57. deg=180, sin=1.22461e-16, cos=-1    << THIS IS CORRECT!
  58.  
  59. deg=270, sinpi=-1, cospi=-0
  60. deg=270, sinpi=-1, cospi=-0
  61. deg=270, sin=-1, cos=-1.83691e-16
  62.  
  63. deg=360, sinpi=0, cospi=1
  64. deg=360, sinpi=0, cospi=1
  65. deg=360, sin=-2.44921e-16, cos=1
  66.  
  67. ---------------------- This is our OS ------------------------
  68. cat /etc/motd
  69. SunOS Release 4.1.2-JLE1.1.2 (GENERIC) #1: Mon Dec 2 19:12:34 JST 1991
  70.  
  71. --
  72. ___________________________________________________________________________
  73. |~~~\    University of Tokyo    | Jari Vaario, jari@ai.rcast.u-tokyo.ac.jp 
  74. |   | /~~~\   /\   /~~~\~~~T~~~ | Research Center for                      
  75. |___/|       /  \  \___    |    |    Advanced Science and Technology/OHlab.
  76. |  \ |      /~~~~\     \   |    | Komaba 4-6-1, Meguro-ku, 153 Tokyo, Japan
  77. |   \ \___//      \\___/   |    | tel. +81-3-3481-4486/fax. +81-3-3481-4585
  78. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  79.