Hi all,

I have submitted the third patch for issue71158.

It is about formula GCD and LCM, if you are interested, you can read that.

Besides, we have something undecided. 
It's about the handling of negative values. After patch 2, I found the formula 
GCD/LCM(-0.0000000000000000000001) will return 0.0. It's because we call 
approxFloor() before the argument value is checked for <0.0.

And what Eike said is that:

>> What do you mean define another threshold for -0.x==0.0?
>> Is it meaning if -0.x>the threshold, then -0.x=0.0,
>> else -0.x=error?

>Yes. Some background: the way how approxFloor() works is it does
>a scaled comparison:

>inline double approxFloor(double a)
>{
>    double b = floor( a );
>    if ( approxEqual( a - 1.0, b ) && !approxEqual( a, b ) )
>        return b + 1.0;
>    return b;
>}

>For details of approxEqual() see sal/inc/rtl/math.hxx

>However, the nature of this algorithm is that the internal threshhold of
>this process is 1/(2**48) ~= 3.55271e-015, let it call epsilon, so if
>abs(a) < epsilon   the result will be pulled towards zero. As
>3.55271e-015 may be quite a large number, depending on context, we could
>check first if the value is smaller than another threshhold we define:

>    epsilon = -1e-123;
>    if (value < 0.0)
>    {
>        if (value < epsilon)
>            ERROR;
>        else
>            value = 0.0;
>    }
>    else
>        value = approxFloor( value);


>> but the threshold is diffcult to ditermine, I think.

>That's true. Maybe someone on the [EMAIL PROTECTED] list has an idea. That's 
>why
>discussing technical details on the mailing list in the end may be
>better than personal mail just between us two :-)

I have modified that in the third patch.
Now only values larger than -1e-123 and <0.0 can cause GCD/LCM = 0.0.
but I don't know whether the threshold is adaptive.

So if you have any good idea, please tell us.
We can make the formula work more effectively. 
Thank you. :)





Best
Lvyue
2008-2-1

Reply via email to