title: How can I use the struct library in python to pack a double into two uint32's
body: <p>So this is what I would like to do:
  I have a double and I need to pack it into binary data and then get the upper four bytes and store them into a uint32 (it has to do with a device driver).</p>
  
  <p>I already do this with floats:</p>
  
  <pre><code>import struct
  import numpy as np
  tmp = struct.pack('&lt;f',float(datatobeconverted))
  dataout = np.uint32(struct.unpack('&lt;I',tmp))
  </code></pre>
  
  <p>I would like to do this with doubles but It doesn't seem to work:</p>
  
  <pre><code>tmp = struct.pack('&lt;d',double(datatobeconverted))
  dataout0 = np.uint32(struct.unpack('&lt;I',tmp[0:3]))
  dataout1 = np.uint32(struct.unpack('&lt;I',tmp[4:7]))
  </code></pre>
  
  <p>Any ideas? By the way, I think the way struct stores binary data is unintuitive and hard to read</p>