title: Converting a floating-point decimal value to a fraction
body: <p>Given a decimal floating-point value, how can you find its fractional equivalent/approximation? For example:</p>
  <pre><code>as_fraction(0.1) -&gt; 1/10
  as_fraction(0.333333) -&gt; 1/3
  as_fraction(514.0/37.0) -&gt; 514/37
  </code></pre>
  <p>Is there a general algorithm that can convert a decimal number to fractional form? How can this be implemented simply and efficiently in C++?</p>