Why does shifting 0xff left by 24 bits result in an incorrect value?
问题 I would like to shift 0xff left by 3 bytes and store it in a uint64_t , which should work as such: uint64_t temp = 0xff << 24; This yields a value of 0xffffffffff000000 which is most definitely not the expected 0xff000000 . However, if I shift it by fewer than 3 bytes, it results in the correct answer. Furthermore, trying to shift 0x01 left by 3 bytes does work. Here's my output: 0xff shifted by 0 bytes: 0xff 0x01 shifted by 0 bytes: 0x1 0xff shifted by 1 bytes: 0xff00 0x01 shifted by 1 bytes