home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / coherent / 6371 < prev    next >
Encoding:
Text File  |  1992-12-22  |  1.8 KB  |  67 lines

  1. Newsgroups: comp.os.coherent
  2. Path: sparky!uunet!munnari.oz.au!penguin!brianw
  3. From: brianw@philips.oz.au (Brian Wallis)
  4. Message-ID: <1992Dec21.123913.2881@philips.oz.au>
  5. Date: Mon, 21 Dec 92 12:39:13 GMT
  6. Organization: Philips Public Telecommunications Systems, Melbourne, Australia
  7. Subject: Floating point: printf "%g" bug?
  8. Lines: 57
  9.  
  10. I've come across a possible anomally in the floating point output from printf
  11. in Coherent 4.0. The program to demonstrate this is appended at the end. It
  12. looks to me like a rounding error.
  13.  
  14. Here are the rusults of running the program on my system...
  15.  
  16.  
  17. 38 - (.13g)38 (.14g)38
  18. 39 - (.13g)39 (.14g)39
  19. 40 - (.13g)40 (.14g)40
  20. 41 - (.13g)41 (.14g)41.00000000000001
  21. 42 - (.13g)42 (.14g)42
  22. 43 - (.13g)43 (.14g)43
  23. 44 - (.13g)44 (.14g)44
  24. 45 - (.13g)45 (.14g)45
  25. 46 - (.13g)46 (.14g)46.00000000000001
  26. 47 - (.13g)47 (.14g)47
  27. 48 - (.13g)48 (.14g)48.00000000000001
  28. 49 - (.13g)49 (.14g)49
  29. 50 - (.13g)50 (.14g)50
  30. 51 - (.13g)51 (.14g)51.00000000000001
  31. 52 - (.13g)52 (.14g)52
  32. 53 - (.13g)53 (.14g)53.00000000000001
  33. 54 - (.13g)54 (.14g)54
  34. 55 - (.13g)55 (.14g)55
  35. 56 - (.13g)56 (.14g)56.00000000000001
  36. 57 - (.13g)57 (.14g)57
  37. 58 - (.13g)58 (.14g)58.00000000000001
  38. 59 - (.13g)59 (.14g)59
  39.  
  40. The extra ...0001 is causing problems in my port of perl. I may have to replace
  41. printf and friends, but then again perhaps the problem is in the floating point
  42. itself?
  43.  
  44. Any clues from anyone?
  45.  
  46. thanks, brian...
  47.  
  48.  
  49. #include <stdio.h>
  50.  
  51. main(argc,argv)
  52.   int argc;
  53.   char *argv[];
  54. {
  55.   int i;
  56.  
  57.   for(i=38;i<60;i++){
  58.     printf("%d - (.13g)%.13g (.14g)%.14g\n",i,(double)i,(double)i);
  59.   }
  60.  
  61. }
  62. -- 
  63. -----------------------------------------------------------------
  64. Brian Wallis <brianw@philips.oz.au>         Phone: +61 3 8813576
  65. Philips Public Telecommunications Systems      Fax: +61 3 8813577
  66. Melbourne, Australia
  67.