What are the chances of getting the same GUID in 1 billion iterations?

守給你的承諾、 提交于 2019-12-10 12:31:33

问题


I am working on a project where I need to generate approximately 1 billion GUIDs.

I know GUIDs are not guaranteed to be unique but are unique almost all of the time.

If I generated a billion GUIDs, what is the probability that there will be a match?


回答1:


http://blogs.msdn.com/b/oldnewthing/archive/2008/06/27/8659071.aspx

The .NET GUID consists of

  • 60 bits of timestamp,
  • 48 bits of computer identifier,
  • 14 bits of uniquifier, and
  • six bits are fixed

So the UUID probability quoted by Oscar does not work here. But if you create all your 1 billion GUIDs from one computer, there is no chance to get a duplicate (except you are playing with the clock ;-)




回答2:


If you are creating the GUIds from the same machine and using the same algorithm then you will not get a collision.




回答3:


http://en.wikipedia.org/wiki/Uuid#Random_UUID_probability_of_duplicates

n probability

68,719,476,736 = 2^36 = 0.0000000000000004 = 4 × 10^−16)

2,199,023,255,552 = 2^41 = 0.0000000000004 = (4 × 10^−13)

70,368,744,177,664 = 2^46 = 0.0000000004 = (4 × 10^−10)



来源:https://stackoverflow.com/questions/3138395/what-are-the-chances-of-getting-the-same-guid-in-1-billion-iterations

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!