Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Enables arc4random_uniform in Swift on Ubuntu, just add this to the top of your main.swift file under the rest of your imports.
#if os(Linux)
import SwiftGlibc
public func arc4random_uniform(_ max: UInt32) -> Int32 {
return (SwiftGlibc.rand() % Int32(max-1))
}
#endif
@monokrome

This comment has been minimized.

Show comment
Hide comment
@monokrome

monokrome Feb 10, 2017

@rymcol Unlike arc4random, doesn't this have modulo bias problems?

monokrome commented Feb 10, 2017

@rymcol Unlike arc4random, doesn't this have modulo bias problems?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment