temp1 =(temp << 8)>>8; when you do this the operation is done and the shift bits are not shreded and the operation is again performed on the same bits where as when you do in 2 lines the bits shifted is deleted and so the result is 6.