lundi 5 novembre 2018

Why does cmath pow give inaquarate anwsers?

In c++ std11:

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, id like to know why both results aren't equal.

Thank you, to anybody that anwsers.

Aucun commentaire:

Enregistrer un commentaire