summaryrefslogtreecommitdiff
path: root/scaddins
diff options
context:
space:
mode:
authorOmkarAcharekar <omkaracharekar12@gmail.com>2022-10-22 01:47:10 +0530
committerStephan Bergmann <sbergman@redhat.com>2022-10-25 08:12:26 +0200
commit4cec1ec1d575ff0328f014de57abb591e3c7ae11 (patch)
tree9104b29f0d18bd0eb83a9287a97f59fcc14de5f4 /scaddins
parent0d47b49c93283d4e5cf4372dd0e981180b995972 (diff)
tdf#145759 Use symbolic constants instead of magic numerical constants
Change-Id: I68f9dd0bbe5a98de35253220dc33382139b4950e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141657 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'scaddins')
-rw-r--r--scaddins/source/analysis/analysishelper.cxx8
-rw-r--r--scaddins/source/pricing/black_scholes.cxx2
2 files changed, 6 insertions, 4 deletions
diff --git a/scaddins/source/analysis/analysishelper.cxx b/scaddins/source/analysis/analysishelper.cxx
index 58f5a4087543..11f5c3abe9dd 100644
--- a/scaddins/source/analysis/analysishelper.cxx
+++ b/scaddins/source/analysis/analysishelper.cxx
@@ -26,7 +26,9 @@
#include <o3tl/any.hxx>
#include <rtl/math.hxx>
#include <algorithm>
+#include <cmath>
#include <memory>
+
#include "analysisdefs.hxx"
#include "analysishelper.hxx"
#include <analysis.hrc>
@@ -1719,7 +1721,7 @@ void Complex::Power( double fPower )
void Complex::Sqrt()
{
- static const double fMultConst = 0.7071067811865475; // ...2440084436210485 = 1/sqrt(2)
+ static const double fMultConst = M_SQRT1_2;
double p = Abs();
double i_ = sqrt( p - r ) * fMultConst;
@@ -1811,14 +1813,14 @@ void Complex::Ln()
void Complex::Log10()
{
Ln();
- Mult( 0.434294481903251828 ); // * log10( e )
+ Mult( M_LOG10E );
}
void Complex::Log2()
{
Ln();
- Mult( 1.442695040888963407 ); // * log2( e )
+ Mult( M_LOG2E );
}
diff --git a/scaddins/source/pricing/black_scholes.cxx b/scaddins/source/pricing/black_scholes.cxx
index 88bdfc999b35..98baa307c100 100644
--- a/scaddins/source/pricing/black_scholes.cxx
+++ b/scaddins/source/pricing/black_scholes.cxx
@@ -93,7 +93,7 @@ static double dnorm(double x) {
}
// cumulative normal distribution (see also ScInterpreter::integralPhi)
static double pnorm(double x) {
- return 0.5 * std::erfc(-x * 0.7071067811865475);
+ return 0.5 * std::erfc(-x * M_SQRT1_2);
}
// binary option cash (domestic)