[Libreoffice-commits] core.git: extensions/source sc/source
Julien Nabet
serval2412 at yahoo.fr
Mon Sep 15 00:57:09 PDT 2014
extensions/source/scanner/grid.cxx | 3 ++-
sc/source/core/tool/interpr2.cxx | 7 ++++---
sc/source/core/tool/interpr3.cxx | 5 +++--
3 files changed, 9 insertions(+), 6 deletions(-)
New commits:
commit a3ad01dc1e07da21182077bd899094fd73f57714
Author: Julien Nabet <serval2412 at yahoo.fr>
Date: Sat Sep 13 20:44:58 2014 +0200
cppcheck: unpreciseMathCall
Change-Id: I440dc3e30ee139d6cb261e1308e48e9b63b52bc8
Reviewed-on: https://gerrit.libreoffice.org/11434
Reviewed-by: Thomas Arnhold <thomas at arnhold.org>
Tested-by: Thomas Arnhold <thomas at arnhold.org>
diff --git a/extensions/source/scanner/grid.cxx b/extensions/source/scanner/grid.cxx
index 98ab441..5a593b0 100644
--- a/extensions/source/scanner/grid.cxx
+++ b/extensions/source/scanner/grid.cxx
@@ -21,6 +21,7 @@
#include <osl/thread.h>
#include <cstdio>
#include <math.h>
+#include <boost/math/special_functions/expm1.hpp>
#include <cmath>
@@ -640,7 +641,7 @@ void GridWindow::ChangeMode(int nType)
{
for( int i = 0; i < m_nValues; i++ )
{
- m_pNewYValues[ i ] = m_fMinY + (m_fMaxY-m_fMinY)*(std::exp((m_pXValues[i]-m_fMinX)/(m_fMaxX-m_fMinX))-1.0)/(M_E-1.0);
+ m_pNewYValues[ i ] = m_fMinY + (m_fMaxY-m_fMinY)*(boost::math::expm1((m_pXValues[i]-m_fMinX)/(m_fMaxX-m_fMinX)))/(M_E-1.0);
}
}
break;
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 1326c5f..f5179a8 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -27,6 +27,7 @@
#include <svl/zforlist.hxx>
#include <svl/sharedstringpool.hxx>
#include <sal/macros.h>
+#include <boost/math/special_functions/log1p.hpp>
#include "attrib.hxx"
#include "sc.hrc"
@@ -1429,7 +1430,7 @@ void ScInterpreter::ScLaufz()
double nFuture = GetDouble();
double nPresent = GetDouble();
double nInterest = GetDouble();
- PushDouble(log(nFuture / nPresent) / log(1.0 + nInterest));
+ PushDouble(log(nFuture / nPresent) / boost::math::log1p(nInterest));
}
}
@@ -1543,9 +1544,9 @@ void ScInterpreter::ScZZR()
PushDouble(-(nBw + nZw)/nRmz);
else if (nFlag > 0.0)
PushDouble(log(-(nInterest*nZw-nRmz*(1.0+nInterest))/(nInterest*nBw+nRmz*(1.0+nInterest)))
- /log(1.0+nInterest));
+ /boost::math::log1p(nInterest));
else
- PushDouble(log(-(nInterest*nZw-nRmz)/(nInterest*nBw+nRmz))/log(1.0+nInterest));
+ PushDouble(log(-(nInterest*nZw-nRmz)/(nInterest*nBw+nRmz))/boost::math::log1p(nInterest));
}
bool ScInterpreter::RateIteration( double fNper, double fPayment, double fPv,
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 0a3ac92..41cb0c0 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -33,6 +33,7 @@
#include <math.h>
#include <vector>
#include <algorithm>
+#include <boost/math/special_functions/log1p.hpp>
using ::std::vector;
using namespace formula;
@@ -587,7 +588,7 @@ double ScInterpreter::GetGamma(double fZ)
if (fZ >= -0.5) // shift to x>=1, might overflow
{
- double fLogTest = lcl_GetLogGammaHelper(fZ+2) - log(fZ+1) - log( fabs(fZ));
+ double fLogTest = lcl_GetLogGammaHelper(fZ+2) - boost::math::log1p(fZ) - log( fabs(fZ));
if (fLogTest >= fLogDblMax)
{
SetError( errIllegalFPOperation);
@@ -620,7 +621,7 @@ double ScInterpreter::GetLogGamma(double fZ)
return log(lcl_GetGammaHelper(fZ));
if (fZ >= 0.5)
return log( lcl_GetGammaHelper(fZ+1) / fZ);
- return lcl_GetLogGammaHelper(fZ+2) - log(fZ+1) - log(fZ);
+ return lcl_GetLogGammaHelper(fZ+2) - boost::math::log1p(fZ) - log(fZ);
}
double ScInterpreter::GetFDist(double x, double fF1, double fF2)
More information about the Libreoffice-commits
mailing list