There is some obvious stuff I feel I should understand here, but I don:t:
void main() { long first = 0xffffffc1; long second = 0x92009019; //correct __int64 correct = (((__int64)first << 32) | 0x00000000ffffffff) & (0xffffffff00000000 | second); //output is 0xffffffc192009019; //incorrect __int64 wrong = (double)(((__int64)first << 32) + second); //output is 0xffffffc092009019; } why does the add operation affect the upper 4 bytes, and how?
(compiler is VC++ 2003)
doubleshouldn't be there, right?mainmust never returnvoid! Its return type is alwaysint. Other compilers correctly flag this as an error.