Каков быстрый и простой способ упаковки знаковых значений в 4 бита? [закрыто] ⇐ Python
-
Гость
Каков быстрый и простой способ упаковки знаковых значений в 4 бита? [закрыто]
I have a python list of integers, each being in the range [-8,7]. I want to pack these values into an array of bytes that i will send down a socket connection. Since these values can be represented by 4 bits in a two's complement representation, it should be possible to pack two such values in each byte. What is a good and relatively fast way of doing this in python? Thanks
Источник: https://stackoverflow.com/questions/781 ... -in-4-bits
I have a python list of integers, each being in the range [-8,7]. I want to pack these values into an array of bytes that i will send down a socket connection. Since these values can be represented by 4 bits in a two's complement representation, it should be possible to pack two such values in each byte. What is a good and relatively fast way of doing this in python? Thanks
Источник: https://stackoverflow.com/questions/781 ... -in-4-bits