fork(2) download
  1. #include <stdio.h>
  2.  
  3. double p10[] = {
  4. 0.1, 0.01, 0.001, 0.0001, 0.00001, 0.000001, 0.0000001, 0.00000001, 0.000000001, 0.0000000001
  5. };
  6.  
  7. int main(void) {
  8. double a = 1;
  9. for (int i = 0 ; i != 10 ; i++) {
  10. double aa = a * 0.1;
  11. double d = aa - p10[i];
  12. printf("%d %.30lf\n", aa == p10[i], d);
  13. a = aa;
  14. }
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0s 2052KB
stdin
Standard input is empty
stdout
1 0.000000000000000000000000000000
1 0.000000000000000000000000000000
1 0.000000000000000000000000000000
1 0.000000000000000000000000000000
1 0.000000000000000000000000000000
0 0.000000000000000000000211758237
0 0.000000000000000000000026469780
0 0.000000000000000000000001654361
0 0.000000000000000000000000206795
0 0.000000000000000000000000025849