title: Decimal to Double conversion in Swift 3
body: <p>I'm migrating a project from <strong>Swift 2.2</strong> to <strong>Swift 3</strong>, and I'm trying to get rid of old Cocoa data types when possible.</p>
  
  <p>My problem is here: migrating <code>NSDecimalNumber</code> to <code>Decimal</code>.</p>
  
  <p>I used to bridge <code>NSDecimalNumber</code> to <code>Double</code> both ways in <strong>Swift 2.2</strong>:</p>
  
  <pre><code>let double = 3.14
  let decimalNumber = NSDecimalNumber(value: double)
  
  let doubleFromDecimal = decimalNumber.doubleValue
  </code></pre>
  
  <p>Now, switching to <strong>Swift 3</strong>:</p>
  
  <pre><code>let double = 3.14
  let decimal = Decimal(double)
  
  let doubleFromDecimal = ???
  </code></pre>
  
  <p><code>decimal.doubleValue</code> does not exist, nor <code>Double(decimal)</code>, not even <code>decimal as Double</code>...
  The only hack I come up with is: </p>
  
  <pre><code>let doubleFromDecimal = (decimal as NSDecimalNumber).doubleValue
  </code></pre>
  
  <p>But that would be completely stupid to try to get rid of <code>NSDecimalNumber</code>, and have to use it once in a while...</p>
  
  <p>Well, either I missed something obvious, and I beg your pardon for wasting your time, or there's a loophole needed to be addressed, in my opinion...</p>
  
  <p>Thanks in advance for your help.</p>
  
  <p><strong>Edit</strong> : Nothing more on the subject on <strong>Swift 4</strong>.</p>
  
  <p><strong>Edit</strong> : Nothing more on the subject on <strong>Swift 5</strong>.</p>