fork download
  1. #include <iostream>
  2. #include <limits>
  3.  
  4. using std::numeric_limits;
  5. using namespace std;
  6.  
  7. int main() {
  8.  
  9. float d = 3.14;
  10. cout.precision(numeric_limits<float>::digits10);
  11. cout << d <<endl;
  12. cout.precision(numeric_limits<float>::digits10 +1);
  13. cout << d <<endl;
  14. cout.precision(numeric_limits<float>::digits10 +2);
  15. cout << d <<endl;
  16. cout.precision(numeric_limits<float>::digits10 +3);
  17. cout << d <<endl;
  18. cout.precision(numeric_limits<float>::digits10 +4);
  19. cout << d <<endl;
  20. cout.precision(numeric_limits<float>::digits10 +5);
  21. cout << d <<endl;
  22. cout.precision(numeric_limits<float>::digits10 +6);
  23. cout << d <<endl;
  24. cout.precision(numeric_limits<float>::digits10 +7);
  25. cout << d <<endl;
  26. cout.precision(numeric_limits<float>::digits10 +8);
  27. cout << d <<endl;
  28. cout.precision(numeric_limits<float>::digits10 +9);
  29. cout << d <<endl;
  30. cout.precision(numeric_limits<float>::digits10 +10);
  31. cout << d <<endl;
  32. cout.precision(numeric_limits<float>::digits10 +11);
  33. cout << d <<endl;
  34. cout.precision(numeric_limits<float>::digits10 +12);
  35. cout << d <<endl;
  36. cout.precision(numeric_limits<float>::digits10 +13);
  37. cout << d <<endl;
  38. cout.precision(numeric_limits<float>::digits10 +14);
  39. cout << d <<endl;
  40. cout.precision(numeric_limits<float>::digits10 +15);
  41. cout << d <<endl;
  42. cout.precision(numeric_limits<float>::digits10 +16);
  43. cout << d <<endl;
  44. cout.precision(numeric_limits<float>::digits10 +17);
  45. cout << d <<endl;
  46. cout.precision(numeric_limits<float>::digits10 +18);
  47. cout << d <<endl;
  48. cout.precision(numeric_limits<float>::digits10 +19);
  49. cout << d <<endl;
  50. cout.precision(numeric_limits<float>::digits10 +20);
  51. cout << d <<endl;
  52. cout.precision(numeric_limits<float>::digits10 +21);
  53. cout << d <<endl;
  54. cout.precision(numeric_limits<float>::digits10 +22);
  55. cout << d <<endl;
  56. cout.precision(numeric_limits<float>::digits10 +23);
  57. cout << d <<endl;
  58.  
  59. cout.precision(numeric_limits<double>::digits10 +1);
  60. cout << d <<endl;
  61. return 0;
  62. }
Success #stdin #stdout 0s 5564KB
stdin
Standard input is empty
stdout
3.14
3.14
3.1400001
3.1400001
3.140000105
3.1400001049
3.1400001049
3.140000104904
3.1400001049042
3.14000010490417
3.140000104904175
3.1400001049041748
3.1400001049041748
3.140000104904174805
3.1400001049041748047
3.14000010490417480469
3.140000104904174804688
3.1400001049041748046875
3.1400001049041748046875
3.1400001049041748046875
3.1400001049041748046875
3.1400001049041748046875
3.1400001049041748046875
3.1400001049041748046875
3.140000104904175