I want to print a decimal number with error at most 10-6.
What does error at most 10-6 mean?
E.g.: 10.35652383,
Which of the following two options is correct?
1)10.356523 or 2)10.356524
As printf("%.6lf") prints with the decimal rounded off to 6 decimal places 10.356524 will be printed.
To print to the nearest
0.000001, use"%.6f"To print to an approximate
0.000001*x, use"%.6e"Alternatively for relative precision: code could use the below when
fabs(x) < 1000000. It is unclear what is wanted whenxis larger.The use of
las in%lfwork the same as without it:%fforprintf().