title: Getting the decimal part of a double in Swift
body: <p>I'm trying to separate the decimal and integer parts of a double in swift. I've tried a number of approaches but they all run into the same issue...</p>
  
  <pre><code>let x:Double = 1234.5678
  let n1:Double = x % 1.0           // n1 = 0.567800000000034
  let n2:Double = x - 1234.0        // same result
  let n3:Double = modf(x, &amp;integer) // same result
  </code></pre>
  
  <p>Is there a way to get 0.5678 instead of 0.567800000000034 without converting to the number to a string?</p>