Skip to content

Instantly share code, notes, and snippets.

@santiaago
Last active August 27, 2017 16:01
Show Gist options
  • Save santiaago/447612af8b900fd3d977 to your computer and use it in GitHub Desktop.
Save santiaago/447612af8b900fd3d977 to your computer and use it in GitHub Desktop.
Random number in a given interval
// 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