我看到,下面的代碼產生的結果如下,任何想法爲什麼是這樣的輸出?C的pow()函數按照頭文件<math.h>不能正常工作
#include <stdio.h>
#include <math.h>
int main() {
int i = 0;
for(i = 0; i < 10; i++) {
printf("%d\t\t\t%d\t\t\t", i, (int)pow(10, i));
printf("%f\n", pow(10, i));
}
return 0;
}
輸出:
0 1 1.000000
1 10 10.000000
2 99 100.000000
3 1000 1000.000000
4 9999 10000.000000
5 100000 100000.000000
6 1000000 1000000.000000
7 9999999 10000000.000000
8 99999999 100000000.000000
9 999999999 1000000000.000000
[pow函數的奇怪行爲]的可能重複(http://stackoverflow.com/questions/18155883/strange-behaviour-of-the-pow-function) – 2015-09-06 05:13:15