When tying to implement mySqrt function in C++, I used the exp() function like this:
int mySqrt(int x) {
// For x = 2147395600
cout << exp(0.5*log(x)) << " "; // It prints 46340
return exp(0.5*log(x)); // But returns 46339
}
I tried to google the reason for this behavior but could not find anything. I even tried using double but still the same output.
Any explanation for this?