home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / bsd / 10901 < prev    next >
Encoding:
Text File  |  1993-01-04  |  1.2 KB  |  43 lines

  1. Path: sparky!uunet!pipex!bnr.co.uk!uknet!cf-cm!myrddin.isl.cf.ac.uk!paul
  2. From: paul@isl.cf.ac.uk (Paul Richards)
  3. Newsgroups: comp.unix.bsd
  4. Subject: Bug in mathlib (i.e. -lfpu)
  5. Message-ID: <1993Jan4.213529.23355@cm.cf.ac.uk>
  6. Date: 4 Jan 93 21:35:28 GMT
  7. Sender: news@cm.cf.ac.uk (Network News System)
  8. Organization: Intelligent Systems Lab, ELSYM, Universiity of Wales, College of 
  9.               Cardiff.
  10. Lines: 31
  11.  
  12. I was getting totally different results from a program when compiled
  13. with the mathlib routines so I thought I'd track down the problem.
  14.  
  15. Anyway, pow seems to mess up the results of expressions when the
  16. numerator of the expression is a function and pow is the denominator.
  17. I'll try and track down the cause tomorrow (It's getting late here).
  18.  
  19. Below is a test program which shows the problem. Compile it with the
  20. stock -lm and with -lfpu and note the difference.
  21.  
  22. Anyone who has used mathlib (Interviews people take note) needs to
  23. check that their code doesn't do this.
  24.  
  25. ----------------
  26.  
  27. #include <math.h>
  28.  
  29. float myproc()
  30. {
  31. return 1.0;
  32. }
  33.  
  34. void main(void)
  35. {
  36.     int i;
  37.  
  38.       for (i=0; i <5; i++)
  39.          printf("test %f\n",myproc()/(float)pow(2.0,1.0));
  40. }
  41.  
  42. ----------------
  43.