If double precision does not guarantee more than 16 significant decimal digits, how is such an output generated by this standard C++ program? Also small value change operations done on "ans" such as ++ans don't alter the screen output. Is the answer "computed" just before printing the result instead of getting stored in IEEE754 double-precision format into "ans" rightaway?
Restating the question - Why such garbage digits that follow first 16 digits produce correct results for powers of 2?
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
double ans = pow(2.0, 700.0);
printf("%.0f\n", ans);
return 0;
}
5260135901548373507240989882880128665550339802823173859498280903068732154297080822113666536277588451226982968856178217713019432250183803863127814770651880849955223671128444598191663757884322717271293251735781376
SOLVED: Also found an explanation here.
Thanks for all the responses!