Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extension ClosedRange where Bound: BinaryFloatingPoint {
- var random: Bound {
- let ratio = Bound(arc4random_uniform(UInt32.max)) / Bound(UInt32.max - 1)
- let offset = (upperBound - lowerBound) * ratio
- return lowerBound + offset
- }
- }
Add Comment
Please, Sign In to add comment