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

Chance of negative ID #38

Open
nixie opened this issue Feb 25, 2019 · 0 comments
Open

Chance of negative ID #38

nixie opened this issue Feb 25, 2019 · 0 comments

Comments

@nixie
Copy link

nixie commented Feb 25, 2019

Hi,
I'm curious about the subtraction of 1 when generating new ID. Why is it here? The output of random.Random().getrandbits(k) is already in range [0,2^(k-1)], so subtracting 1 can result in new ID equal to -1 (even though with probability 1/2^64).

return guid_rng.getrandbits(64) - 1

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