Created
July 17, 2014 00:53
-
-
Save nh7a/a287167abc932d85708b to your computer and use it in GitHub Desktop.
auto casting Float to Double
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Float { | |
func __conversion() -> Double { return Double(self) } | |
} | |
let two = 2.0 | |
let n1 = 1 / 2.0 // Ok | |
let n2 = Float(1) / 2.0 // Ok | |
let n3 = Double(1) / 2.0 // Ok | |
let n4 = CGFloat(1) / 2.0 // Ok | |
let n5 = 1 / two // Ok | |
let n6 = Float(1) / two // Error | |
let n7 = Double(1) / two // Ok | |
let n8 = CGFloat(1) / two // Error for 32-bit system. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment