fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. double largestCfor(double A)
  5. {
  6. double C = nextafter(1.0, 0);
  7. while (C*A >= A)
  8. C = nextafter(C, 0);
  9. return C;
  10. }
  11.  
  12. int main() {
  13. double C = 1;
  14. for (double i = 0x1p-1022; isfinite(i); i *= 2) // loop through all possible exponents
  15. {
  16. double c = largestCfor(i);
  17. if (c < C) C = c;
  18. }
  19.  
  20. printf("C = %.30f\n", C);
  21. printf("nextafter(1.0, 0) = %.30f\n", nextafter(1.0, 0));
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 4468KB
stdin
Standard input is empty
stdout
C                 = 0.999999999999999777955395074969
nextafter(1.0, 0) = 0.999999999999999888977697537484