From 4cec1ec1d575ff0328f014de57abb591e3c7ae11 Mon Sep 17 00:00:00 2001 From: OmkarAcharekar Date: Sat, 22 Oct 2022 01:47:10 +0530 Subject: 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 --- scaddins/source/analysis/analysishelper.cxx | 8 +++++--- scaddins/source/pricing/black_scholes.cxx | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'scaddins') 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 #include #include +#include #include + #include "analysisdefs.hxx" #include "analysishelper.hxx" #include @@ -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) -- cgit