home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / amiga / programm / 13337 < prev    next >
Encoding:
Text File  |  1992-09-13  |  4.0 KB  |  154 lines

  1. Path: sparky!uunet!mcsun!Germany.EU.net!Informatik.Uni-Dortmund.DE!jenny!ch
  2. From: ch@jenny.informatik.uni-dortmund.de (Carsten Heyl)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: IEEEDPCmp-Bug in 37.1 ?
  5. Date: 14 Sep 1992 10:17:03 GMT
  6. Organization: CS Department, Dortmund University, Germany
  7. Lines: 140
  8. Sender: ch@jenny (Carsten Heyl)
  9. Distribution: world
  10. Message-ID: <191oqvINNkaj@fbi-news.Informatik.Uni-Dortmund.DE>
  11. Reply-To: ch@irb.informatik.uni-dortmund.de
  12. NNTP-Posting-Host: jenny
  13.  
  14. Hello,
  15.  
  16. i think i found a Bug in IEEEDPCmp of my
  17. mathieeedoubbas.library V 37.1 and I would like to now
  18. if it is still present in newer versions.
  19.  
  20. If I missed a post of this problems or other problems of
  21. mathieeedoubbas.library please give me a hint.
  22.  
  23. The problem did occur when comparing negative numbers.
  24. Your output may differ if yout compiler does not use 
  25. IEEEDPCmp(d1,d2) .
  26. This problem was discovered while using gcc 2.2.2.
  27.  
  28. I wrote a short patch Program which patches Word 39 and 40
  29. of IEEEDPCmp (in running version of library).
  30.  
  31.                 *(sptr+39) = 0x66ac;
  32.                 *(sptr+40) = 0x4e71;
  33.  
  34. And as you can see I get what I expected.
  35.  
  36. Sorry if this post is too long.
  37. If this bug is still present in recent versions, please
  38. submit it to CBM.
  39.  
  40. Ciao,
  41.     Carsten
  42.  
  43. Here is the Output of my test-program:
  44. Show mathieeedoubbas.library 37.1 bug of IEEEDPCmp(d1,d2)
  45.  
  46. d1 = -10.00000000000000000, d2 = -10.00000000000000178
  47.  
  48. d1 <d2: 0 (should be 0)
  49. d1<=d2: 0 (should be 0)
  50. d1 >d2: 1 (should be 1)
  51. d1>=d2: 1 (should be 1)
  52.  
  53. d2 <d1: 0 (should be 1)
  54. d2<=d1: 0 (should be 1)
  55. d2 >d1: 1 (should be 0)
  56. d2>=d1: 1 (should be 0)
  57.  
  58. IEEEDPCmp(d1,d2): 1 (should be 1)
  59. IEEEDPCmp(d2,d1): 1 (should be -1)
  60.  
  61. Patch of IEEEDPCmp successfully installed
  62.  
  63. Show mathieeedoubbas.library 37.1 bug of IEEEDPCmp(d1,d2)
  64.  
  65. d1 = -10.00000000000000000, d2 = -10.00000000000000178
  66.  
  67. d1 <d2: 0 (should be 0)
  68. d1<=d2: 0 (should be 0)
  69. d1 >d2: 1 (should be 1)
  70. d1>=d2: 1 (should be 1)
  71.  
  72. d2 <d1: 1 (should be 1)
  73. d2<=d1: 1 (should be 1)
  74. d2 >d1: 0 (should be 0)
  75. d2>=d1: 0 (should be 0)
  76.  
  77. IEEEDPCmp(d1,d2): 1 (should be 1)
  78. IEEEDPCmp(d2,d1): -1 (should be -1)
  79.  
  80. Test-program:
  81. /*
  82.         demonstrate bug of mathieeedoubbas.library 37.1
  83. */
  84.  
  85. #include <stdio.h>
  86.  
  87. #include <inline/mathieeedoubbas.h>
  88. #include <inline/exec.h>
  89.  
  90. struct Library *MathIeeeDoubBasBase;
  91.  
  92. union convert
  93. {
  94.     double d;
  95.     struct {
  96.         unsigned int s:1;
  97.         unsigned int e:11;
  98.         unsigned int m1:20;
  99.         unsigned int m2;
  100.     } IEEE;
  101. };
  102.  
  103. int main()
  104. {
  105.         double d1, d2;
  106.         union convert conv;
  107.  
  108.         MathIeeeDoubBasBase = OpenLibrary("mathieeedoubbas.library", 0);
  109.         if(MathIeeeDoubBasBase == 0)
  110.         {
  111.                 printf("could not open mathieeedoubbas.library\n");
  112.                 exit(1);
  113.         }
  114.  
  115.         d1 = -10.0;
  116.         conv.d = d1;
  117.         conv.IEEE.m2++;
  118.     d2 = conv.d;
  119.  
  120. #define TEST(a,b,c) printf("%s: %d (should be %d)\n", a, b, c);
  121.  
  122.  
  123.         printf("Show mathieeedoubbas.library 37.1 bug of IEEEDPCmp(d1,d2)\n\n");
  124.         printf("d1 = %.17f, d2 = %.17f\n\n", d1, d2);
  125.  
  126.         TEST("d1 <d2", d1<d2 , 0);
  127.         TEST("d1<=d2", d1<=d2, 0);
  128.         TEST("d1 >d2", d1>d2 , 1);
  129.         TEST("d1>=d2", d1>=d2, 1);
  130.         printf("\n");
  131.         TEST("d2 <d1", d2<d1 , 1);
  132.         TEST("d2<=d1", d2<=d1, 1);
  133.         TEST("d2 >d1", d2>d1 , 0);
  134.         TEST("d2>=d1", d2>=d1, 0);
  135.         printf("\n");
  136.         TEST("IEEEDPCmp(d1,d2)", IEEEDPCmp(d1,d2), 1);
  137.         TEST("IEEEDPCmp(d2,d1)", IEEEDPCmp(d2,d1), -1);
  138.  
  139.         CloseLibrary(MathIeeeDoubBasBase);
  140. }
  141.  
  142.  
  143. -- 
  144.   Carsten Heyl                          ch@irb.informatik.uni-dortmund.de
  145.   Computer Science Department - IRB     
  146.   University of Dortmund               
  147.   D-4600 Dortmund 50,PO-Box 500500, Germany    Office: GB V R. 325, x4700
  148. -------------------------------------------------------------------------------
  149. I agree that this issue continues to be a major source of misunderstanding,
  150. BUT either I misunderstand your statement of my position above, or else
  151. I do understand and I disagree with your statement of my position above.
  152.                 (Jim Adcock, comp.std.c++)
  153.  
  154.