Created
August 7, 2015 15:04
-
-
Save heinrisch/4eb575f816beeec1348a to your computer and use it in GitHub Desktop.
Very useful operator for not being precise..
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
prefix operator ~ {} | |
prefix func ~ (number: Float) -> Float { | |
let random = Float(arc4random()) / Float(UINT32_MAX) | |
return number + (0.1*number - 0.2*number*random) // +-10% | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment