fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. inline bool timer_timestamp_less_1(uint32_t t1,uint32_t t2){
  5. return (t1-t2)>(1U<<31);
  6. }
  7.  
  8. inline bool timer_timestamp_less_2(uint32_t t1,uint32_t t2){
  9. return t1 < t2;
  10. }
  11.  
  12.  
  13. int main(){
  14. // Equivalent
  15. cout << timer_timestamp_less_1(1, 2) << endl;
  16. cout << timer_timestamp_less_2(1, 2) << endl;
  17. // Not Equivalent
  18. uint32_t a = (1U<<31) + (1U << 30);
  19. cout << a <<endl;
  20. cout << timer_timestamp_less_1(a, 0) << endl;
  21. cout << timer_timestamp_less_2(a, 0) << endl;
  22. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
1
1
3221225472
1
0