round-off error in std::pow(std::complex<T>, double) in C++11

John W. Eaton jwe@octave.org
Sat Jan 26 16:37:00 GMT 2013


On 01/25/2013 01:54 PM, Marc Glisse wrote:

> Implementing this optimization in the compiler when the exponent is a
> compile-time constant seems like a good and simple idea in any case :-)

If that was done, would a function like

   bool foo (std::complex<double>& x, int y)
   {
      return std::pow (x, y) == std::pow (x, 2);
   }

maybe return fals if called with y = 2, assuming the compiler could not 
determine the value of y at compile time?

That seems like a bad feature to me.

jwe



More information about the Libstdc++ mailing list