问题
I'm trying to build up a packet (adaption field)
I'm trying to build the PCR packet, but im a bit confused on python bitwise operators....
adapt_header_3 = (0x1f45db5e4df << (9 + 6)) # adapt_header_3 = 2149055849695
# d5 7d 51 05 7f 27 - This is what the correct result should look like
print(hex(adapt_header_3)) ## << but im getting this for adapt_header_3 0xfa2edaf26f8000
So I expect:
d5 7d 51 05 7f 27 (6 bytes)
But i'm getting:
fa 2e da f2 6f 80 00 00 (8 bytes)
UPDATE: Bit more of a test im using this:
adapt_header_1 = 0x7
adapt_header_2 = 0x10
adapt_header_3 = 0x1f45db5e4df
adapt_header = 0x0
adapt_header = adapt_header | (adapt_header_1 << (48 + 8))
adapt_header = adapt_header | (adapt_header_2 << (48))
adapt_header = adapt_header | (adapt_header_3 << (9 + 6))
print(hex(adapt_header))
To build this:
来源:https://stackoverflow.com/questions/58657928/python-need-help-understanding-bit-wise-and-byte-manipulation-unexpected-behavio