title: How to reliably separate decimal and floating parts from a number?
body: <p>This is not a duplicate of <a href="https://stackoverflow.com/questions/6681743/splitting-a-number-into-the-integer-and-decimal-parts-in-python">this</a>, I'll explain here.</p>
  
  <p>Consider <code>x = 1.2</code>. I'd like to separate it out into <code>1</code> and <code>0.2</code>. I've tried all these methods as outlined in the linked question:</p>
  
  <pre><code>In [370]: x = 1.2
  
  In [371]: divmod(x, 1)
  Out[371]: (1.0, 0.19999999999999996)
  
  In [372]: math.modf(x)
  Out[372]: (0.19999999999999996, 1.0)
  
  In [373]: x - int(x)
  Out[373]: 0.19999999999999996
  
  In [374]: x - int(str(x).split('.')[0])
  Out[374]: 0.19999999999999996
  </code></pre>
  
  <p>Nothing I try gives me exactly <code>1</code> and <code>0.2</code>. </p>
  
  <p>Is there any way to <em>reliably</em> convert a floating number to its decimal and floating point equivalents that is not hindered by the limitation of floating point representation? </p>
  
  <p>I understand this might be due to the limitation of how the number is itself stored, so I'm open to any suggestion (like a package or otherwise) that overcomes this. </p>
  
  <p>Edit: Would prefer a way that didn't involve string manipulation, <em>if possible</em>.</p>