title: How do I convert a floating point number into erlang time format (and vice versa)?
body: <p>I am trying to convert an erlang time format tuple, <code>{megasec,sec,microsec}</code>, into a floating point number and back again.</p>
  
  <p>I can do this one way, e.g.: </p>
  
  <pre><code>{Megasec,Sec,Usec} = erlang:now().
  Total = Megasec*1000000+Sec+Usec/1000000. 
  1352802601.427
  </code></pre>
  
  <p>But I am struggling to convert this number back to the time format. I have a general idea to divide by 1000000 and round but I get rounding errors. e.g.</p>
  
  <pre><code>Mega = erlang:round(Total/1000000).
  1353
  </code></pre>
  
  <p>If I could get this accurately I could apply similar steps to get <code>Seconds</code> and <code>Microseconds</code>.</p>
  
  <p>Any ideas?</p>