Why does cmath pow give inaccurate answers?
In C++11: pow(1061,6); // = 1426567426713180416 Check the last 3 digits. I know for sure that result is wrong, because 1061^6 = 1426567426713180361. But this other method does it right: long a =1; for(int i=0; i<6 ; i++){ a*=1061; } cout << a; // = 1426567426713180361 pow is included from cmath. If anyone knows, I'd like to know why both results aren't equal. std::pow will return double for the integral case and this answer here explains the first integral where double can not longer exactly represent every integral starts at 9007199254740993 after this we may have integers that can not be