Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main(void)
- {
- int variable1;
- int variable2;
- unsigned variable3;
- unsigned variable4;
- for(int i=0; i < 10; ++i)
- {
- variable2 = i;
- variable1 = i%3*i+i; //some kind "randomness"
- if((variable1 &= ~variable2) == (variable1 ^= variable2) )
- std::cout << "'signed int' is the same," << "index: "<< i << std::endl;
- }
- for(int i=0; i < 10; ++i)
- {
- variable3 = i;
- variable4 = i%3*i+i; //some kind "randomness"
- if((variable3 &= ~variable4) == (variable3 ^= variable4) )
- std::cout << "'unsigned int' is the same," << "index: "<< i << std::endl;
- }
- //mixed type pretty useless
- for(int i=0; i < 10; ++i)
- {
- variable1 = i;
- variable4 = i%3*i+i; //some kind "randomness"
- if((variable1 &= ~variable4) == (variable1 ^= variable4) )
- std::cout << "'signed mixed with unsigned' is the same," << "index: "<< i << std::endl;
- }
- //mixed type reversed
- for(int i=0; i < 10; ++i)
- {
- variable3 = i;
- variable1 = i%3*i+i; //some kind "randomness"
- if((variable3 &= ~variable1) == (variable3 ^= variable1) )
- std::cout << "'unsigned mixed with signed' is the same," << "index: "<< i << std::endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement