You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
294 B
Python
15 lines
294 B
Python
2 years ago
|
import struct
|
||
|
|
||
|
|
||
|
def double2wordarray(data):
|
||
|
"""
|
||
|
double -> 16bit * 4
|
||
|
little-end
|
||
|
"""
|
||
|
return struct.unpack('<HHHH', struct.pack('<d', data))
|
||
|
|
||
|
|
||
|
def wordarray2double(data):
|
||
|
assert isinstance(data, (tuple, list))
|
||
|
return struct.unpack('<d', struct.pack('<HHHH', *data))[0]
|