Created
October 15, 2020 19:52
-
-
Save foxicode/ed997e48e552452ee70549404073b9f0 to your computer and use it in GitHub Desktop.
Simple numeric conversions in Swift
This file contains hidden or 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
| import Foundation | |
| // Int to Double | |
| var i: Int = 1 | |
| var d: Double = Double(i) | |
| // Double to Int | |
| var i1: Int = Int(d) | |
| var i2: Int = Int(1.1) // -> 1 | |
| var i3: Int = Int(1.9) // -> 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment