[Bug libstdc++/89991] Complex numbers: Calculation of imaginary part is not correct

2019-04-06 Thread t.sprodowski at web dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991

--- Comment #3 from t.sprodowski at web dot de ---
Octave 4.2.2: ans = 2.6284e-20 + 4.2924e-04i

[Bug libstdc++/89991] Complex numbers: Calculation of imaginary part is not correct

2019-04-05 Thread t.sprodowski at web dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991

--- Comment #1 from t.sprodowski at web dot de ---
Created attachment 46095
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46095=edit
Source file

Source file to illustrate this bug.

[Bug libstdc++/89991] New: Complex numbers: Calculation of imaginary part is not correct

2019-04-05 Thread t.sprodowski at web dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89991

Bug ID: 89991
   Summary: Complex numbers: Calculation of imaginary part is not
correct
   Product: gcc
   Version: 8.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: t.sprodowski at web dot de
  Target Milestone: ---

Following calculation of the complex number leads to a wrong imaginary part:


#include 
#include 
#include 

int main(int argc, char *argv[])
{
  std::complex val = std::complex(-1.8425031517782417e-07,
-0.0);
  std::complex 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.

Compilation was done with gnu 8.2.0 and 7.3.0 on Ubuntu 18.04:

g++ -c -pipe -g -std=gnu++1y -Wall -W -D_REENTRANT -fPIC
-DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_CORE_LIB -I../testPrecision -I.
-isystem /usr/include/x86_64-linux-gnu/qt5 -isystem
/usr/include/x86_64-linux-gnu/qt5/QtCore -I.
-I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o main.o
../testPrecision/main.cpp