Why do I get the wrong values when I print an int
using printf("%f
", myNumber)
?
I don't understand why it prints fine with %d
, but not with %f
. Shouldn't it just add extra zeros?
int a = 1;
int b = 10;
int c = 100;
int d = 1000;
int e = 10000;
printf("%d %d %d %d %d
", a, b, c, d, e); //prints fine
printf("%f %f %f %f %f
", a, b, c, d, e); //prints weird stuff
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…