title: How to convert ieee754 doubles into fraction of two integers?
body: <p>How do I get <code>long long</code> (64-bit) values <code>a</code> and <code>b</code> from a <code>double</code> (64-bit) value <code>d</code> such that <code>(double)a / b</code> more or less equals <code>d</code>?  Is this possible (without loss of precision)?</p>
  
  <p>I've tried along the lines of this but it didn't get anywhere so I'm thinking maybe I've got the wrong idea:</p>
  
  <pre><code>union ieee754_double u;
  u.d = d;
  
  long long a = (long long)u.ieee.mantissa0 &lt;&lt; 32 | u.ieee.mantissa1;
  long long b = (long long)1 &lt;&lt; (u.ieee.exponent + IEEE754_DOUBLE_BIAS);
  </code></pre>