fork(1) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. {
  8. int i = 0;
  9. float epsilon_f = 1.0;
  10. while(1.0f + epsilon_f > 1.0f)
  11. {
  12. epsilon_f = epsilon_f / 2.0f;
  13. i++;
  14. }
  15. cout << "Machine epsilon for float type: " << epsilon_f << endl;
  16. cout << "The amount of iterations for float type: " << i << endl;
  17. }
  18. {
  19. int i = 0;
  20. float epsilon_f = 1.0;
  21. while(1.0 + epsilon_f > 1.0)
  22. {
  23. epsilon_f = epsilon_f / 2.0;
  24. i++;
  25. }
  26. cout << "Machine epsilon for double type: " << epsilon_f << endl;
  27. cout << "The amount of iterations for double type: " << i << endl;
  28. }
  29.  
  30. }
  31.  
Success #stdin #stdout 0s 5472KB
stdin
Standard input is empty
stdout
Machine epsilon for float type: 5.96046e-08
The amount of iterations for float type: 24
Machine epsilon for double type: 1.11022e-16
The amount of iterations for double type: 53