fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <cmath>
  4.  
  5. int main()
  6. {
  7. int y;
  8. double a, b = 0.0, x = 1e-2, z;
  9.  
  10. double a_string = std::atof("-0.1");
  11. double a_inline = -0.1;
  12.  
  13. std::cout << "Inline:: ";
  14. a = a_inline;
  15. for (y = 1 ; (z = a + y * x) < b; ++y){
  16. std::cout << y << ": " << z << " | ";
  17. }
  18.  
  19. std::cout << "\nString:: ";
  20. a = a_string;
  21. for (y = 1 ; (z = a + y * x) < b; ++y){
  22. std::cout << y << ": " << z << " | ";
  23. }
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
Inline:: 1: -0.09 | 2: -0.08 | 3: -0.07 | 4: -0.06 | 5: -0.05 | 6: -0.04 | 7: -0.03 | 8: -0.02 | 9: -0.01 | 
String:: 1: -0.09 | 2: -0.08 | 3: -0.07 | 4: -0.06 | 5: -0.05 | 6: -0.04 | 7: -0.03 | 8: -0.02 | 9: -0.01 | 10: -3.46945e-18 |