[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice
Subject: KSpread patch
From: Daniel Herring <herring () eecs ! ku ! edu>
Date: 2002-02-27 20:27:38
[Download RAW message or body]
Attached is a patch consisting of minor changes to KSpread.
This file is a diff against the latest CVS version (2-27-2002).
This patch adds one new function [eps()], a little documentation about the
structure of built-in functions, and some minor GUI changes to the
"Formula Editor".
If others could check this patch and comment on/commit it, I would be
appreciative.
Thanks,
Daniel Herring
nuntius@ku.edu
["kspread.diff" (TEXT/PLAIN)]
? kspread/KSpread.kdevelop
Index: kspread/kspread_dlg_formula.cc
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_dlg_formula.cc,v
retrieving revision 1.79
diff -u -3 -p -r1.79 kspread_dlg_formula.cc
--- kspread/kspread_dlg_formula.cc 2002/01/03 16:34:38 1.79
+++ kspread/kspread_dlg_formula.cc 2002/02/27 20:14:30
@@ -84,6 +84,7 @@ KSpreadDlgFormula::KSpreadDlgFormula( KS
grid1->addWidget( functions, 2, 0 );
selectFunction = new QPushButton( page );
+ QToolTip::add(selectFunction, i18n("Insert function") );
selectFunction->setPixmap( BarIcon( "down", KIcon::SizeSmall ) );
grid1->addWidget( selectFunction, 3, 0 );
@@ -138,7 +139,7 @@ KSpreadDlgFormula::KSpreadDlgFormula( KS
grid2->addStretch( 10 );
- m_tabwidget->addTab( m_input, i18n("&Edit") );
+ m_tabwidget->addTab( m_input, i18n("&Parameters") );
m_tabwidget->setTabEnabled( m_input, FALSE );
m_tabwidget->setCurrentPage( index );
Index: kspread/kspread_interpreter.cc
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_interpreter.cc,v
retrieving revision 1.134
diff -u -3 -p -r1.134 kspread_interpreter.cc
--- kspread/kspread_interpreter.cc 2002/02/08 16:22:15 1.134
+++ kspread/kspread_interpreter.cc 2002/02/27 20:14:30
@@ -132,6 +132,9 @@ static bool approx_equal (double a, doub
*
* Module with global functions like "sin", "cos", "sum" etc.
*
+ * Note: These modules must be registered in \
kspread_interpreter::kspreadCreateModule_KSpread + * They should also be \
documented in KSPREAD/extensions/builtin.xml + *
*********************************************************************/
static bool kspreadfunc_sin( KSContext& context )
@@ -1373,6 +1376,16 @@ static bool kspreadfunc_PI( KSContext& c
return true;
}
+static bool kspreadfunc_eps( KSContext& context )
+{
+#warning This should adjust according to the actual number system used (float, \
double, long double, ...) + if( !KSUtil::checkArgumentsCount( context, 0, "eps", \
true ) ) + return false;
+
+ context.setValue( new KSValue(DBL_EPSILON));
+ return true;
+}
+
static bool kspreadfunc_rand( KSContext& context )
{
// QValueList<KSValue::Ptr>& args = context.value()->listValue();
@@ -5134,6 +5147,7 @@ static KSModule::Ptr kspreadCreateModule
//compatibility with kspread1.0
module->addObject( "ENT", new KSValue( new KSBuiltinFunction( module, \
"ENT",kspreadfunc_INT) ) ); module->addObject( "PI", new KSValue( new \
KSBuiltinFunction( module, "PI",kspreadfunc_PI) ) ); + module->addObject( "eps", new \
KSValue( new KSBuiltinFunction( module, "eps",kspreadfunc_eps) ) ); \
module->addObject( "rand", new KSValue( new KSBuiltinFunction( module, \
"rand",kspreadfunc_rand) ) ); module->addObject( "REPT", new KSValue( new \
KSBuiltinFunction( module, "REPT",kspreadfunc_REPT) ) );
Index: kspread/extensions/builtin.xml
===================================================================
RCS file: /home/kde/koffice/kspread/extensions/builtin.xml,v
retrieving revision 1.80
diff -u -3 -p -r1.80 builtin.xml
--- kspread/extensions/builtin.xml 2002/01/10 13:04:16 1.80
+++ kspread/extensions/builtin.xml 2002/02/27 20:14:30
@@ -1010,6 +1010,19 @@
<GroupName>Analytic</GroupName>
<Function>
+ <Name>eps</Name>
+ <Type>Float</Type>
+ <Help>
+ <Text>eps() returns the machine epsilon; this is the difference between 1 and the \
next largest floating-point number. Because computers use a finite number of digits, \
roundoff error is inherent (but usually insignificant) in all calculations.</Text> \
+ <Syntax>eps()</Syntax> + <Example>On most systems, this returns \
2^-52=2.2204460492503131e-16</Example> + <Example>0.5*eps() returns the "unit round"; \
this value is interesting because it is the largest number x where (1+x)-1=0 (due to \
roundoff errors).</Example> + <Example>eps() is so small that KSpread displays \
1+eps() as 1</Example> + <Example>Pick a number x between 0 and eps(). Observe that \
1+x rounds x to either 0 or eps() by using the equation (1+x)-1</Example> + \
</Help> + </Function>
+
+ <Function>
<Name>pow</Name>
<Type>Float</Type>
<Parameter>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic