fork(2) download
  1. #include <string>
  2. #include <iostream>
  3. #include <cfloat>
  4. #include <cassert>
  5.  
  6. int main()
  7. {
  8. char *end;
  9. float f1 = strtof("1.0000000596046448", &end);
  10. float f2 = std::stof("1.0000000596046448");
  11. float f3 = (float) std::stod("1.0000000596046448");
  12.  
  13. std::cout << "f1 - 1 = " << f1 - 1 << "\n";
  14. std::cout << "f2 - 1 = " << f2 - 1 << "\n";
  15. std::cout << "f3 - 1 = " << f3 - 1 << "\n";
  16. }
  17.  
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
f1 - 1 = 1.19209e-07
f2 - 1 = 1.19209e-07
f3 - 1 = 0