I'm working on CSES number spiral problem and I've noticed that c++ isn't calculating it right?
ans = pow(y, 2) - (x-1);
This is the code and I have x and y both set as 1000000000.
cout << "pow =" << pow(y, 2) << "\n";
cout << "x-1 =" << (x - 1) << "\n";
I've put this right before the calculation and pow shows up correct with 1e18 and x-1 is also correct with 999999999.
cout << 1000000000000000000 - 999999999 << "\n";
If I manually write it like this it works but pow(y,2) - (x-1) doesn't. It will give me an answer of 999999999000000000.