fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. typedef union {
  5. int i32;
  6. float d32;
  7. } dbl_32;
  8. double machine_eps (float value)
  9. {
  10. dbl_32 s;
  11. s.d32 = value;
  12. s.i32++;
  13. return s.d32 - value;
  14. }
  15.  
  16. int
  17. main(int argc, char *argv[])
  18. {
  19. float a, b, f;
  20. a=123456789;
  21. b=123456788;
  22. cout << machine_eps(a) << "; " << machine_eps(b);
  23. return 0;
  24.  
  25. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
8; 8