Last active
August 27, 2017 16:01
-
-
Save santiaago/447612af8b900fd3d977 to your computer and use it in GitHub Desktop.
Random number in a given interval
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
// computes a random number in the specified interval centered in zero. | |
func randInInterval(min int, max int) float64 { | |
r := rand.New(rand.NewSource(time.Now().UnixNano())) | |
size := float64(max - min) | |
return r.Float64()*size + float64(min) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment