home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / os / linux / 10604 < prev    next >
Encoding:
Text File  |  1992-09-13  |  2.2 KB  |  56 lines

  1. Path: sparky!uunet!know!hri.com!spool.mu.edu!sol.ctr.columbia.edu!caen!batcomputer!munnari.oz.au!bruce.cs.monash.edu.au!monu6!aurora.cc.monash.edu.au!int177c
  2. From: int177c@aurora.cc.monash.edu.au (Jae Won)
  3. Newsgroups: comp.os.linux
  4. Subject: gcc 2.2.2 math lib bug???
  5. Keywords: weirdness
  6. Message-ID: <1992Sep13.161713.8191@monu6.cc.monash.edu.au>
  7. Date: 13 Sep 92 16:17:13 GMT
  8. Sender: news@monu6.cc.monash.edu.au (Usenet system)
  9. Organization: Monash University
  10. Lines: 44
  11.  
  12. Hi.
  13.  
  14.     I found a weidness in gcc2.2.2d. It may be my silly code but I tested
  15. the code with gcc compiler at uni(gcc...not sure of the version) and it worked
  16. fine...well, like what I expected. The code is a edited fragment of a code 
  17. I am writing to do a monte carlo stuff. I use exp() function.
  18.     Here is what goes wrong. When I enter values of 1000 for values of
  19. x, I get a huge number when what I was expecting was rather small number(
  20. more like 0). I get zero at uni gcc compiler so I guess there is nothing 
  21. wrong with my code...It is not just 1000 that makes the thing go
  22. funny, but numbers around 1000....x+y.....seems to give me funny values.
  23. But then again, when I enter values much larger, then the code works okay and
  24. gives me something pretty close to zero.
  25.     Okay, I am running pl4 without 387 and I have set the emulation on(would it
  26. work(the kernel) if I have set emulation to off? coz I am not 100% sure if 
  27. I did set it off. I never had any crashes so I assumed that I compiled it right)Also, I would like to mention that if I have small value for x then the thing
  28. seems to work fine.
  29.     Okay, I had further experiments with the code and at x value of 709, 
  30. this is the output I get...
  31.  
  32. [pasted using xterm...so I am not making up anything..:)]
  33. p0 2:12 linux[136] a.out 709                                                  ~
  34. Current I: <.16781e-309
  35.  
  36. I have never seen such output so can someone help me to the right
  37. direction? Or is it a bug?(nah...I don't think I can ever find a bug..;-> )
  38. Anyway, any help would be appreciated.
  39.  
  40. Here is the code:
  41. ****start code
  42. #include <stdio.h>
  43. #include <math.h>
  44. double x;
  45. double I;       /*the value we are after*/
  46. main (int argc, char **argv)
  47. {
  48.         double temp;
  49.         x= atof(argv[1]);
  50.         I= exp(-x);
  51.         printf("Current I: %g\n", I);
  52. }
  53. ******end code
  54.  
  55. Jae
  56.