Skip to content Skip to sidebar Skip to footer

Creating 16 And 24-bit Integers From Binary File

I'm modifying an existing Python app that reads a binary file. The format of the file is changing a bit. Currently, one field is defined as bytes 35-36 of the record. The specs

Solution 1:

Simply read 24 bit (I assume in big endian, since the original code is in that format as well ):

val = struct.unpack('>I', b'\x00' + reg[34:37])

Post a Comment for "Creating 16 And 24-bit Integers From Binary File"