C: i got different results with pow(10,2) and pow(10,j), j=2;
问题 this one prints 100: int j=2; int i= pow(10,2); printf("%d\n", i); and this one prints 99: int j=2; int i= pow(10,j); printf("%d\n", i); why? 回答1: What's going on is that you have a C implementation whose standard library has a very low quality implementation of pow which is returning inexact results even when the exact result is representable in the type ( double ). The call to pow(10,2) seems to producing the value just below 100.0 , which, when rounded to an integer, yields 99. The reason