arc4random - Swift random float between 0 and 1 -


running xcode6-beta4, in public osx yosemite beta.

i'm trying random float between 0 , 1 can't seem type conversions work.

func randomcgfloat() -> cgfloat {     return cgfloat(arc4random()) / uint32_max } 

i'm getting 'cgfloat' not convertible 'uint8' error

try initializing divisor float well, la:

cgfloat(float(arc4random()) / float(uint32_max)) 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -