I'm trying to do some simple phase calculations in C++ and discovered that I was sometimes getting the wrong results from std::arg
when using real values as input.
According to the documentation on cppreference:
Additional overloads are provided for float, double, long double, and all integer types, which are treated as complex numbers with zero imaginary component.
However this does not seem to be the case, because these two calls return different results.
auto x1 = std::arg(std::complex<double>{ -1.0, 0.0 });
// x1 = PI (3.14159...)
auto x2 = std::arg(-1.0);
// x2 = 0
Did i just find a bug in the MSVC implementation of the standard library, or am I missing something obvious?
Compiler info:
Microsoft (R) C/C++ Optimizing Compiler Version 19.21.27702.2 for x86
Aucun commentaire:
Enregistrer un commentaire