我知道這是一個常見問題。不過,我找不到一個明確的直接答案。爲什麼printf不使用科學記數法?
16^54 = 1.0531229167e+65 (this is the result I want)
當我使用pow(16,54)
,我得到:
105312291668557186697918027683670432318895095400549111254310977536.0
代碼如下:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
void main(){
double public;
double a = 16;
double b = 54;
public = (pow(a,b));
printf("%.21f\n", public);
}
代碼執行:
GCC的main.c -lm
我做錯了什麼?
所以你想要科學記數法? –
也讀了關於'g'格式說明符。 –