代码之家  ›  专栏  ›  技术社区  ›  Diskdrive

在10亿次迭代中获得相同的guid的机会有多大?

  •  14
  • Diskdrive  · 技术社区  · 14 年前

    我正在做一个项目,我需要生成大约10亿个guid。

    我知道guid不一定是独一无二的,但几乎所有时候都是独一无二的。

    如果我生成了十亿个guid,那么匹配的概率是多少?

    3 回复  |  直到 14 年前
        1
  •  15
  •   Hinek    14 年前

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

    .NET GUID包括

    • 60位时间戳,
    • 48位计算机标识符,
    • 14位uniquifier,和

        2
  •  5
  •   Robin Day    14 年前

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

        3
  •  2
  •   sbi    14 年前

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

    n概率

    68719476736=2^36=0.00000000000000004=4_10_16)

    2199023255552=2^41=0.000000000004=(4_10_13)

    70368744177664=2^46=0.000000000004=(4_10__10)