Please note that there are two ways to convert this to double, depending on whether the processor is large, but it is better to know which one you need.
>>> from struct import unpack >>> value = ['\x7f', '\x15', '\xb7', '\xdb', '5', '\x03', '\xc0', '@'] >>> unpack('<d', ''.join(value))[0] 8198.42076767492 >>> unpack('>d', ''.join(value))[0] 1.4893584640656973e+304
and just for fun - here's how to explicitly decode a double
>>> value = ['\x7f', '\x15', '\xb7', '\xdb', '5', '\x03', '\xc0', '@'] >>> bytes = map(ord,reversed(value)) >>> sign = (1,-1)[bytes[0]>>7] >>> exp = ((0x7f&bytes[0])<<4) + (bytes[1]>>4) - 1023 >>> mantissa = reduce(lambda x,y: (x<<8) + y, bytes[2:], bytes[1]&0xf) >>> sign*2**exp*(1+mantissa*2**-52) 8198.4207676749193
source share