Created
March 26, 2013 21:24
-
-
Save ayende/5249408 to your computer and use it in GitHub Desktop.
Two code samples showing differences between shift operators in C# & C++
Any idea why?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| uint32_t x = 25426435u; | |
| std::cout << x << std::endl; | |
| uint32_t a = (x >> 17); | |
| uint32_t b = (x << 15); | |
| std::cout <<a << " " << b << " " << (a | b) << std::endl; | |
| //OUTPUT: | |
| // 25426435 | |
| // 193 4244733952 4244734145 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| uint x = 254262435u; | |
| Console.WriteLine(x); | |
| uint a = (x >> 17); | |
| uint b = (x << 15); | |
| Console.WriteLine(a + " " + b+ " " + (a | b)); | |
| // OUTPUT: | |
| // 254262435 | |
| // 1939 3729883136 3729885075 | |
Yup, that's it.
So, SELECT isn't broken then? Damn...!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
x in cs file has different value. there is 2 between 6 and 4.