fork download
  1. /*
  2. Example of floating point precision.
  3. Author: Peter R. Bloomfield.
  4. Web: avidinsight.uk
  5. */
  6.  
  7. #include <iostream>
  8. #include <iomanip>
  9. using namespace std;
  10.  
  11. int main() {
  12. float f1 = 0.12345123451234512345f;
  13. float f2 = 0.00000000000000012345f;
  14.  
  15. cout << fixed << setprecision(20);
  16. cout << "f1 = " << f1 << endl;
  17. cout << "f2 = " << f2;
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
f1 = 0.12345123291015625000
f2 = 0.00000000000000012345