I want to control the number of exponent digits after 'e' in C printf %e
?
For example, C printf("%e")
result 2.35e+03
, but I want 2.35e+003
, I need 3 digits of exponent, how do I use printf
?
Code:
#include<stdio.h>
int main()
{
double x=34523423.52342353;
printf("%.3g\n%.3e",x,x);
return 0;
}
Result: http://codepad.org/dSLzQIrn
3.45e+07
3.452e+07
I want
3.45e+007
3.452e+007
But interestingly, I got the right results in Windows with MinGW.