mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
fix: Fixed issue with Windows CI test - M_PI doesn't work on Windows CI
This commit is contained in:
parent
1708de2296
commit
52f918a4ff
@ -12,6 +12,11 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Global constant for pi to work with Windows environment
|
||||||
|
*/
|
||||||
|
const double pi = 3.14159265358979323846;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Complex to represent complex numbers as a field.
|
* Class Complex to represent complex numbers as a field.
|
||||||
*/
|
*/
|
||||||
@ -64,13 +69,13 @@ class Complex {
|
|||||||
if (this->re > 0) {
|
if (this->re > 0) {
|
||||||
return std::atan(this->im / this->re);
|
return std::atan(this->im / this->re);
|
||||||
} else if (this->re < 0 && this->im >= 0) {
|
} 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) {
|
} 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) {
|
} else if (this->re == 0 && this->im > 0) {
|
||||||
return M_PI / 2;
|
return pi / 2;
|
||||||
} else if (this->re == 0 && this->im < 0) {
|
} else if (this->re == 0 && this->im < 0) {
|
||||||
return -M_PI / 2;
|
return -pi / 2;
|
||||||
} else {
|
} else {
|
||||||
throw std::invalid_argument("Undefined Value");
|
throw std::invalid_argument("Undefined Value");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user