Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go中如何生成区间随机数 #5

Open
wisecsj opened this issue Dec 28, 2018 · 1 comment
Open

Go中如何生成区间随机数 #5

wisecsj opened this issue Dec 28, 2018 · 1 comment

Comments

@wisecsj
Copy link
Owner

wisecsj commented Dec 28, 2018

func RandInt64(min, max int64) int64 {
	if min >= max || min == 0 || max == 0 {
		return max
	}
	return rand.Int63n(max-min) + min
}
@wisecsj
Copy link
Owner Author

wisecsj commented Dec 28, 2018

左闭右开 [min,max)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant