Search code examples
c++functionmathpow

c++ pow function- invalid result?


Why is the output of the dResult invalid ?
Env: Visual Studio 2008

int _tmain(int argc, _TCHAR* argv[])  
{  
   double dN = - 0.091023604111478473 ;  
   double dD = 0.127777777777777;  
   double dResult =  pow( dN,dD );   
   //dResult = -1.#IND000000000000  
   return 0;  
}   

Solution

  • See http://www.cplusplus.com/reference/clibrary/cmath/pow/

    double pow (double base, double exponent );
    

    "If base is negative and exponent is not an integral value, or if base is zero and exponent is negative, a domain error occurs, setting the global variable errno to the value EDOM."