Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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;  
}   
like image 660
user85917 Avatar asked Sep 25 '26 04:09

user85917


1 Answers

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."

like image 81
Loïc Février Avatar answered Sep 26 '26 18:09

Loïc Février



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!