Use d
to write double precision floats:
s = struct.pack('d'*len(data), *data)
f
is single precision only. See the Format characters section of the struct
module documentation:
For the
'f'
and'd'
conversion codes, the packed representation uses the IEEE 754 binary32 (for'f'
) or binary64 (for'd'
) format, regardless of the floating-point format used by the platform.