title: How to convert from IEEE Python float to Microsoft Basic float
body: <p>I got Python float value and I need to convert it in to Microsoft Basic Float (MBF) format.
  Luckily, Got some code from internet that does the reverse.</p>
  
  <pre><code>def fmsbin2ieee(self,bytes):
      """Convert an array of 4 bytes containing Microsoft Binary floating point
      number to IEEE floating point format (which is used by Python)"""
      as_int = struct.unpack("i", bytes)
      if not as_int:
          return 0.0
      man = long(struct.unpack('H', bytes[2:])[0])
      exp = (man &amp; 0xff00) - 0x0200
      if (exp &amp; 0x8000 != man &amp; 0x8000):
          return 1.0
          #raise ValueError('exponent overflow')
      man = man &amp; 0x7f | (man &lt;&lt; 8) &amp; 0x8000
      man |= exp &gt;&gt; 1
      bytes2 = bytes[:2]
      bytes2 += chr(man &amp; 255)
      bytes2 += chr((man &gt;&gt; 8) &amp; 255)
      return struct.unpack("f", bytes2)[0]
  </code></pre>
  
  <p>Now I need to reverse this process, but no success yet. Any help please.</p>