Why is Google Chrome's Math.random number generator not *that* random?

后端 未结 3 1606
挽巷
挽巷 2020-12-05 11:03

I ran into an odd \"bug\" today when I was running some unit tests in various browsers. I had run the tests in Firefox many times before today, and even IE but apparently no

3条回答
  •  既然无缘
    2020-12-05 11:22

    Apparently Math.random() in V8 only works with 32 bit values (and didn't even correctly randomize all of those in the past). And with 32 bits, the probability of a collision reaches 50% around 2^16 = 65k values...

提交回复
热议问题