I was using unsigned long long int for some calculations but
std::cout << std::setprecision(30) << 900000000000001i64+4*pow(10, 16);
Gives Output:40900000000000000
and this
std::cout << std::setprecision(30) << 900000000000011i64+4*pow(10, 16);
Gives Output:40900000000000008
Now i have no idea what is happening i tried removing i64
tries printing 4*pow(10, 16)
gives the correct result 40000000000000000
also tried printing 40900000000000011
directly, it prints the correct result. It works fine for power of 10^14 but after that it starts to behave strangely.
Can someone explain what is happening?