fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. int main(int argc, char *argv[]) {
  5. // double/float, rounding errors do not cancel out
  6. std::cout << "double/float: " << std::setprecision(20) << 3.5 / 0.1f << std::endl;
  7. // double/double, rounding errors cancel out
  8. std::cout << "double/double: " << std::setprecision(20) << 3.5 / 0.1 << std::endl;
  9. return 0;
  10. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
double/float: 34.999999478459365321
double/double: 35