https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #2 from kargl at gcc dot gnu.org ---
(In reply to t.sprodowski from comment #0)
> Following calculation of the complex number leads to a wrong imaginary part:
>
>
> #include <complex>
> #include <iomanip>
> #include <iostream>
>
> int main(int argc, char *argv[])
> {
> std::complex<double> val = std::complex<double>(-1.8425031517782417e-07,
> -0.0);
> std::complex<double> testExp = std::pow(val, 0.5);
> std::cout << "textExp: " << std::setprecision(30) << testExp << std::endl;
> return 0;
> }
>
> Result is:
> (2.6283607659835830609796003783e-20,-0.000429243887758258178214548772544),
> but it should be
> (2.628360765983583e-20, 0.0004292438877582582), obtained from Visual Studio,
> MATLAB and Octave.
>
What version of Octave. I get
>> z = complex(-1.8425031517782417e-07, -0.0)
z = -0.00000018425 - 0.00000000000i
>> z**0.5
ans = 2.6284e-20 - 4.2924e-04i
which agrees with clang++ version 7.0.1 (and apparently g++
which I haven't tested).