fork(2) download
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. int Foo(float a)
  6. {
  7. cout << "\nint Foo(float a)\na: " << a << endl;
  8.  
  9. int b = static_cast<int>(a);
  10.  
  11. cout << "int b = a: " << b << endl;
  12.  
  13. return b;
  14. }
  15.  
  16. int main()
  17. {
  18. int a = 0x7FFFFFFF;
  19. float b = static_cast<float>(a);
  20. int c = static_cast<int>(b);
  21.  
  22. cout << "\nint main()\nint a: " << a << endl;
  23. cout << "float b = a: " << fixed << setprecision(0) << b << endl;
  24. cout << "int c = b: " << c << endl;
  25.  
  26. cout << "\nreturn main\nFoo(a): " << Foo(static_cast<float>(a)) << endl << endl;
  27.  
  28. return EXIT_SUCCESS;
  29. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
int main()
int a: 2147483647
float b = a: 2147483648
int c = b: 2147483647

int Foo(float a)
a: 2147483648
int b = a: -2147483648

return main
Foo(a): -2147483648