From: ch@jenny.informatik.uni-dortmund.de (Carsten Heyl)
Newsgroups: comp.sys.amiga.programmer
Subject: IEEEDPCmp-Bug in 37.1 ?
Date: 14 Sep 1992 10:17:03 GMT
Organization: CS Department, Dortmund University, Germany
Distribution: world
Reply-To: ch@irb.informatik.uni-dortmund.de
NNTP-Posting-Host: jenny

Hello,

i think i found a Bug in IEEEDPCmp of my
mathieeedoubbas.library V 37.1 and I would like to now
if it is still present in newer versions.

If I missed a post of this problems or other problems of
mathieeedoubbas.library please give me a hint.

The problem did occur when comparing negative numbers.
Your output may differ if yout compiler does not use 
IEEEDPCmp(d1,d2) .
This problem was discovered while using gcc 2.2.2.

I wrote a short patch Program which patches Word 39 and 40
of IEEEDPCmp (in running version of library).

                *(sptr+39) = 0x66ac;
                *(sptr+40) = 0x4e71;

And as you can see I get what I expected.

Sorry if this post is too long.
If this bug is still present in recent versions, please
submit it to CBM.

Ciao,
	Carsten

Here is the Output of my test-program:
Show mathieeedoubbas.library 37.1 bug of IEEEDPCmp(d1,d2)

d1 = -10.00000000000000000, d2 = -10.00000000000000178

d1 <d2: 0 (should be 0)
d1<=d2: 0 (should be 0)
d1 >d2: 1 (should be 1)
d1>=d2: 1 (should be 1)

d2 <d1: 0 (should be 1)
d2<=d1: 0 (should be 1)
d2 >d1: 1 (should be 0)
d2>=d1: 1 (should be 0)

IEEEDPCmp(d1,d2): 1 (should be 1)
IEEEDPCmp(d2,d1): 1 (should be -1)

Patch of IEEEDPCmp successfully installed

Show mathieeedoubbas.library 37.1 bug of IEEEDPCmp(d1,d2)

d1 = -10.00000000000000000, d2 = -10.00000000000000178

d1 <d2: 0 (should be 0)
d1<=d2: 0 (should be 0)
d1 >d2: 1 (should be 1)
d1>=d2: 1 (should be 1)

d2 <d1: 1 (should be 1)
d2<=d1: 1 (should be 1)
d2 >d1: 0 (should be 0)
d2>=d1: 0 (should be 0)

IEEEDPCmp(d1,d2): 1 (should be 1)
IEEEDPCmp(d2,d1): -1 (should be -1)

Test-program:
/*
        demonstrate bug of mathieeedoubbas.library 37.1
*/

#include <stdio.h>

#include <inline/mathieeedoubbas.h>
#include <inline/exec.h>

struct Library *MathIeeeDoubBasBase;

union convert
{
    double d;
    struct {
        unsigned int s:1;
        unsigned int e:11;
        unsigned int m1:20;
        unsigned int m2;
    } IEEE;
};

int main()
{
        double d1, d2;
        union convert conv;

        MathIeeeDoubBasBase = OpenLibrary("mathieeedoubbas.library", 0);
        if(MathIeeeDoubBasBase == 0)
        {
                printf("could not open mathieeedoubbas.library\n");
                exit(1);
        }

        d1 = -10.0;
        conv.d = d1;
        conv.IEEE.m2++;
	d2 = conv.d;

#define TEST(a,b,c) printf("%s: %d (should be %d)\n", a, b, c);


        printf("Show mathieeedoubbas.library 37.1 bug of IEEEDPCmp(d1,d2)\n\n");
        printf("d1 = %.17f, d2 = %.17f\n\n", d1, d2);

        TEST("d1 <d2", d1<d2 , 0);
        TEST("d1<=d2", d1<=d2, 0);
        TEST("d1 >d2", d1>d2 , 1);
        TEST("d1>=d2", d1>=d2, 1);
        printf("\n");
        TEST("d2 <d1", d2<d1 , 1);
        TEST("d2<=d1", d2<=d1, 1);
        TEST("d2 >d1", d2>d1 , 0);
        TEST("d2>=d1", d2>=d1, 0);
        printf("\n");
        TEST("IEEEDPCmp(d1,d2)", IEEEDPCmp(d1,d2), 1);
        TEST("IEEEDPCmp(d2,d1)", IEEEDPCmp(d2,d1), -1);

        CloseLibrary(MathIeeeDoubBasBase);
}


-- 
  Carsten Heyl                          ch@irb.informatik.uni-dortmund.de
  Computer Science Department - IRB     
  University of Dortmund               
  D-4600 Dortmund 50,PO-Box 500500, Germany	Office: GB V R. 325, x4700
-------------------------------------------------------------------------------
I agree that this issue continues to be a major source of misunderstanding,
BUT either I misunderstand your statement of my position above, or else
I do understand and I disagree with your statement of my position above.
				(Jim Adcock, comp.std.c++)