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

List:       koffice-devel
Subject:    ROUNDUP in kspread
From:       Hasso Tepper <hasso () estpak ! ee>
Date:       2001-07-31 18:48:06
[Download RAW message or body]

ROUNDUP function doesn't behave correctly with whole numbers.

ROUNDUP(7)=8 ;-))

Something like this patch should fix it. I'm not a programmer (tooooo 
little experience because of lack of time :(() so I'll let developers 
check that, but this patch works for me.

regards,

-- 
Hasso Tepper
KDE Estonian Team
["roundup.patch" (text/x-diff)]

Index: kspread_interpreter.cc
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_interpreter.cc,v
retrieving revision 1.95
diff -u -3 -p -r1.95 kspread_interpreter.cc
--- kspread_interpreter.cc	2001/07/02 19:08:19	1.95
+++ kspread_interpreter.cc	2001/07/31 18:46:04
@@ -2537,9 +2537,13 @@ static bool kspreadfunc_roundup( KSConte
                 return false;
         digits=args[1]->intValue();
         }
-
-  result=floor(args[0]->doubleValue()*pow(10,digits)+1)/pow(10,digits);
-  context.setValue( new KSValue( result) );
+	
+	if (floor(args[0]->doubleValue()) == args[0]->doubleValue()) 
+		result = args[0]->doubleValue();
+	else 
+		result=floor(args[0]->doubleValue()*pow(10,digits)+1)/pow(10,digits);
+  
+	context.setValue( new KSValue( result) );
 
   return true;
 }

_______________________________________________
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