title: Issue in parsing float number in swift?
body: <p>Today I come across a very strange situation while getting value from dictionary.I have made two cases here.</p>
  
  <p><strong>Case 1</strong> </p>
  
  <p>if I write code below </p>
  
  <pre><code>let str = "{\"num\":2}"
  
  var dict = convertToDictionary(text: str)!
  
  if let num = dict["num"] as? Float {
      print("Value is \(num)")
  } else {
      print("parse error")
  }
  
  func convertToDictionary(text: String) -&gt; [String: Any]? {
      if let data = text.data(using: .utf8) {
          do {
              return try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
          } catch {
              print(error.localizedDescription)
          }
      }
      return nil
  }
  </code></pre>
  
  <p>As you can see value for key <code>num</code> is <code>Integer</code> but while fetching value from dictionary I expect value as <code>Float</code>. so it should go to else block but it prints the value.</p>
  
  <p><strong>Case 2</strong></p>
  
  <pre><code>var test = 2
  var dict:[String:Any] = [String:Any]()
  dict["num"] = test
  if let num = dict["num"] as? Float {
          print("Value is \(num)")
  } else {
          print("parse error")
  }
  </code></pre>
  
  <p>As I have not defined data type so by default it should be integer here &amp; I expect value to be <code>Float</code>. This does work as I expect
  Now here is does not print value it show the <code>parse error</code></p>
  
  <p>Please explain to me why this is happening ?</p>