Originally Posted by
xErath
It's just a extra info how the number is formated.
that means: put up to 15 digits on the left side of the point, and up to 30 digit on the right side. something like
000000000000000.000000000000000000000000000000
trailing zeros are disposed.
Not exactly. It means, "use at least 15 characters to represent the whole shebang, but use 30 digits after the decimal point".
Originally Posted by
Lionmane
Is there a way to print any number of digits to the left side of the decimal & none on the right?
Code:
#include <stdio.h>
int main(void)
{
double d = 12345678901.2345;
printf("d = %45.30f\n", d);
printf("d = %.0f\n", d);
return 0;
}
/* my output
d = 12345678901.23450088000000000000000000000
d = 12345678901
*/
[edit]
Code:
#include <stdio.h>
int main(void)
{
double d = 12345678901.2345;
int any_number = 40;
printf("d = '%45.30f'\n", d);
printf("d = '%*.0f'\n", any_number, d);
return 0;
}
/* my output
d = ' 12345678901.23450088000000000000000000000'
d = ' 12345678901'
*/