/* A very simple question asked me by my dormitory students is to convert the string output after the number is in reverse order to a numerical value. The students use the common function pow, and the code logic is correct, but I don't understand why the answer is wrong, and it's only one or two. With the help of Tom, I began to realize the loss of pow precision. check cplusplus.com to find the following problems: double pow (double base, double exponent); long double pow (long double base, long double exponent); float pow (float base, float exponent); double pow (double base, int exponent); long double pow (long double base, int exponent); pow function does not exist pow (int), also That is to say, 10 of the input pow (10, n) will first be converted to double, which leads to an error when the number is large. It seems that common functions also need to pay attention to the details! */# Include <stdio. h> # include <math. h> int a [1000]; int main () {int I, x, n = 0, t, sum = 0, j = 0; scanf ("% d ", & I); x = I; printf ("in reverse order:"); while (x) {t = x % 10; printf ("% d", t ); a [j ++] = t; x/= 10;} printf ("\ n");/* for (int I = 0; I <j; I ++) sum = sum * 10 + a [I]; */while (j> = 0) {-- j; sum + = a [j] * (int) (pow (10, n) + 0.5); // If 0.5 is not added here and rounded to int, the precision will be lost. n ++ ;} printf ("sum = % d \ n", sum); return 0 ;}