openoffice-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r1444110 - in /openoffice/trunk/main: sal/inc/rtl/math.h sal/inc/rtl/math.hxx sal/rtl/source/math.cxx sal/util/sal.map sc/source/core/inc/interpre.hxx sc/source/core/tool/interpr5.cxx
Date Fri, 08 Feb 2013 16:31:56 GMT
Author: pfg
Date: Fri Feb  8 16:31:55 2013
New Revision: 1444110

URL: http://svn.apache.org/r1444110
Log:
i114430 - AOO Calc: 0^0=1 and it should be indeterminate.

Many spreadsheets and math packages set the value of POWER( 0, 0)
to 1 as that sometimes is required for some calculations. This
is also done by the standard C99 libc pow() function.

In mathematical terms the value is an indeterminate form and
in strict mathematical sense such value should at least be
considered with caution.

OpenFormula permits implementation defined values of 0, 1
or error in this case. We shall now return NaN.

Clean some headers while here.

Modified:
    openoffice/trunk/main/sal/inc/rtl/math.h
    openoffice/trunk/main/sal/inc/rtl/math.hxx
    openoffice/trunk/main/sal/rtl/source/math.cxx
    openoffice/trunk/main/sal/util/sal.map
    openoffice/trunk/main/sc/source/core/inc/interpre.hxx
    openoffice/trunk/main/sc/source/core/tool/interpr5.cxx

Modified: openoffice/trunk/main/sal/inc/rtl/math.h
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sal/inc/rtl/math.h?rev=1444110&r1=1444109&r2=1444110&view=diff
==============================================================================
--- openoffice/trunk/main/sal/inc/rtl/math.h (original)
+++ openoffice/trunk/main/sal/inc/rtl/math.h Fri Feb  8 16:31:55 2013
@@ -396,6 +396,21 @@ double SAL_CALL rtl_math_round(double fV
  */
 double SAL_CALL rtl_math_pow10Exp(double fValue, int nExp) SAL_THROW_EXTERN_C();
 
+/** Similar to pow() with stricter exception handling for indeterminate values.
+
+    powr is part of the IEEE 754 2008 Floating Point Standard.
+
+    @param fValue
+    The value to be raised.
+
+    @param fExp
+    The exponent.
+
+    @return
+    powr(fValue, fExp)
+ */
+double SAL_CALL rtl_math_powr(double fValue, double fExp) SAL_THROW_EXTERN_C();
+
 /** Rounds value to 15 significant decimal digits.
 
     @param fValue

Modified: openoffice/trunk/main/sal/inc/rtl/math.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sal/inc/rtl/math.hxx?rev=1444110&r1=1444109&r2=1444110&view=diff
==============================================================================
--- openoffice/trunk/main/sal/inc/rtl/math.hxx (original)
+++ openoffice/trunk/main/sal/inc/rtl/math.hxx Fri Feb  8 16:31:55 2013
@@ -186,6 +186,13 @@ inline double pow10Exp(double fValue, in
     return rtl_math_pow10Exp(fValue, nExp);
 }
 
+/** A wrapper around rtl_math_powr.
+ */
+inline double powr(double fValue, int fExp)
+{
+    return rtl_math_powr(fValue, fExp);
+}
+
 /** A wrapper around rtl_math_approxValue.
  */
 inline double approxValue(double fValue)

Modified: openoffice/trunk/main/sal/rtl/source/math.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sal/rtl/source/math.cxx?rev=1444110&r1=1444109&r2=1444110&view=diff
==============================================================================
--- openoffice/trunk/main/sal/rtl/source/math.cxx (original)
+++ openoffice/trunk/main/sal/rtl/source/math.cxx Fri Feb  8 16:31:55 2013
@@ -1113,6 +1113,19 @@ double SAL_CALL rtl_math_expm1( double f
     return (fe-1.0) * fValue / log(fe);
 }
 
+double SAL_CALL rtl_math_powr( double fValue,  double fExp ) SAL_THROW_EXTERN_C()
+{
+    if ((fValue == 0.0  && fExp == 0.0) ||
+	(rtl::math::isInf( fExp ) && !rtl::math::isSignBitSet( fExp )) ||
+	(rtl::math::isInf( fValue ) && !rtl::math::isSignBitSet( fValue )))
+    {
+        double fResult;
+        ::rtl::math::setNan( &fResult );
+        return fResult;
+    }
+    return pow(fValue, fExp);
+}
+
 
 double SAL_CALL rtl_math_log1p( double fValue ) SAL_THROW_EXTERN_C()
 {

Modified: openoffice/trunk/main/sal/util/sal.map
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sal/util/sal.map?rev=1444110&r1=1444109&r2=1444110&view=diff
==============================================================================
--- openoffice/trunk/main/sal/util/sal.map (original)
+++ openoffice/trunk/main/sal/util/sal.map Fri Feb  8 16:31:55 2013
@@ -625,10 +625,12 @@ UDK_3.11 { # AOO 3.4
         osl_setThreadName;
 } UDK_3.10;
 
-UDK_3.12 { # AOO 3.5
+UDK_3.12 { # AOO 4.0
     global:
         osl_loadAsciiModule;
         osl_loadAsciiModuleRelative;
+
+        rtl_math_powr;
 } UDK_3.11;
 
 PRIVATE_1.0 {

Modified: openoffice/trunk/main/sc/source/core/inc/interpre.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sc/source/core/inc/interpre.hxx?rev=1444110&r1=1444109&r2=1444110&view=diff
==============================================================================
--- openoffice/trunk/main/sc/source/core/inc/interpre.hxx (original)
+++ openoffice/trunk/main/sc/source/core/inc/interpre.hxx Fri Feb  8 16:31:55 2013
@@ -609,13 +609,6 @@ void ScGetDate();
 void ScGetTime();
 void ScGetDiffDate();
 void ScGetDiffDate360();
-void ScPower();
-void ScAmpersand();
-void ScAdd();
-void ScSub();
-void ScMul();
-void ScDiv();
-void ScPow();
 void ScCurrent();
 void ScStyle();
 void ScDde();
@@ -669,6 +662,13 @@ void ScIntercept();
 double ScGetGCD(double fx, double fy);
 void ScGCD();
 void ScLCM();
+void ScPower();
+void ScAmpersand();
+void ScAdd();
+void ScSub();
+void ScMul();
+void ScDiv();
+void ScPow();
 //-------------------------- Matrixfunktionen ---------------------------------
 
 void ScMatValue();

Modified: openoffice/trunk/main/sc/source/core/tool/interpr5.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sc/source/core/tool/interpr5.cxx?rev=1444110&r1=1444109&r2=1444110&view=diff
==============================================================================
--- openoffice/trunk/main/sc/source/core/tool/interpr5.cxx (original)
+++ openoffice/trunk/main/sc/source/core/tool/interpr5.cxx Fri Feb  8 16:31:55 2013
@@ -1611,14 +1611,14 @@ void ScInterpreter::ScPow()
             if (bFlag)
             {   for ( SCSIZE i = 0; i < nCount; i++ )
                     if (pMat->IsValue(i))
-                        pResMat->PutDouble(pow(fVal,pMat->GetDouble(i)), i);
+                        pResMat->PutDouble(::rtl::math::powr(fVal,pMat->GetDouble(i)),
i);
                     else
                         pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), i);
             }
             else
             {   for ( SCSIZE i = 0; i < nCount; i++ )
                     if (pMat->IsValue(i))
-                        pResMat->PutDouble(pow(pMat->GetDouble(i),fVal), i);
+                        pResMat->PutDouble(::rtl::math::powr(pMat->GetDouble(i),fVal),
i);
                     else
                         pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), i);
             }
@@ -1628,7 +1628,7 @@ void ScInterpreter::ScPow()
             PushIllegalArgument();
     }
     else
-        PushDouble(pow(fVal1,fVal2));
+        PushDouble(::rtl::math::powr(fVal1,fVal2));
 }
 
 void ScInterpreter::ScSumProduct()



Mime
View raw message