From 52f918a4ffb11aec4fbc4b22d026e2e0a39b867d Mon Sep 17 00:00:00 2001 From: Tajmeet Singh Date: Tue, 23 Jun 2020 16:33:54 +0100 Subject: [PATCH] fix: Fixed issue with Windows CI test - M_PI doesn't work on Windows CI --- math/complex_numbers.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/math/complex_numbers.cpp b/math/complex_numbers.cpp index 4ae5c493b..9d6ede15d 100644 --- a/math/complex_numbers.cpp +++ b/math/complex_numbers.cpp @@ -12,6 +12,11 @@ #include #include +/** + * Global constant for pi to work with Windows environment + */ +const double pi = 3.14159265358979323846; + /** * Class Complex to represent complex numbers as a field. */ @@ -64,13 +69,13 @@ class Complex { if (this->re > 0) { return std::atan(this->im / this->re); } else if (this->re < 0 && this->im >= 0) { - return std::atan(this->im / this->re) + M_PI; + return std::atan(this->im / this->re) + pi; } else if (this->re < 0 && this->im < 0) { - return std::atan(this->im / this->re) - M_PI; + return std::atan(this->im / this->re) - pi; } else if (this->re == 0 && this->im > 0) { - return M_PI / 2; + return pi / 2; } else if (this->re == 0 && this->im < 0) { - return -M_PI / 2; + return -pi / 2; } else { throw std::invalid_argument("Undefined Value"); }