fork download
  1. #include <iostream>
  2. #include <limits>
  3. using namespace std;
  4.  
  5. int main() {
  6. cout << sizeof(void*)*8 << " bits pointers\n";
  7.  
  8. const int ubits = sizeof (unsigned)*8;
  9. const int ullbits = sizeof (unsigned long long)*8;
  10. cout << ubits << " bits for an unsigned\n";
  11. cout << ullbits << " bits for a long long \n";
  12.  
  13. unsigned utest=numeric_limits<unsigned>::max();
  14. unsigned long long ulltest=numeric_limits<unsigned long long>::max();
  15.  
  16. cout << "unsigned "<<utest << " rshift by " << ubits << " = "
  17. << (utest>>ubits)<<endl;
  18. cout << "unsigned long long "<<ulltest << " rshift by " << ullbits << "= "
  19. << (ulltest>>ullbits)<<endl;
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
32 bits pointers
32 bits for an unsigned
64 bits for a long long 
unsigned 4294967295 rshift by 32 = 0
unsigned long long 18446744073709551615 rshift by 64= 0