Created
November 4, 2016 02:37
-
-
Save endodoug/0e2f2b8dc5b2e95e459b16432a02ce49 to your computer and use it in GitHub Desktop.
Random Numbers - Swift 3
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
func randomFloat(from from:CGFloat, to:CGFloat) -> CGFloat { | |
let rand:CGFloat = CGFloat(Float(arc4random()) / 0xFFFFFFFF) | |
return (rand) * (to - from) + from | |
} | |
func randomInt(n: Int) -> Int { | |
return Int(arc4random_uniform(UInt32(n))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment