[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: ROUNDUP in kspread
From:       Hasso Tepper <hasso () estpak ! ee>
Date:       2001-08-01 17:39:52
[Download RAW message or body]

Seems that comparing two floating point values if they are equal or 
not doesn't have point :). I digged into openoffice code how they 
handle this and seems that they implemented approximate comparing for 
this kind of situations.

/// 2**-48 bzw. 3.5527136788005e-015 fuer ApproxEqual Skalierung
#define SOMA_MIN_PRECISION  (1.0 / (16777216.0 * 16777216.0))

inline BOOL SolarMath::ApproxEqual( double a, double b )
{
    if ( a == b )
        return TRUE;
    double x = a - b;
    return (x < 0.0 ? -x : x)  <  ((a < 0.0 ? -a : a) *
	SOMA_MIN_PRECISION);
}

So, something similar must be done in Kspread as well. Btw, gnumeric 
and staroffice have same problem with roundup function.

And ceil function has problem too. Try =ceil(0,07*100). Doesn't look 
correct :).

I can try to make correct patch myself but I think that it takes 
awful lot of time because of my little programming experience and 1.1 
release is too close.

regards,

-- 
Hasso Tepper
KDE Estonian Team
_______________________________________________
Koffice-devel mailing list
Koffice-devel@master.kde.org
http://master.kde.org/mailman/listinfo/koffice-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic