我们如何在Java中生成非常大的随机数?我说的是10000位数吗?我知道我们必须使用BigInteger,但是我们该怎么做呢?做这样的事情最有效的方法是什么?请提供一个小例子.谢谢.
How can we generate very large random number in java? I am talking something like 10000 digits? I know we have to use BigInteger but how can we do this? What is the most efficent way of doing something like this? Please provide a small example. Thank you.
推荐答案好吧,一种方法是转到 Random 并下载二进制随机文件之一.这些文件是由大气噪声生成的,因此它是非常随机的.我在国际象棋引擎中将它用于Zobrist键.
Well, one way is to go to Random and download a one of the binary random files. The files are generated from atmospheric noise, so it's very random. I used it for Zobrist keys in my chess engine.
或者,你可以去
BigInteger b = new BigInteger(256, new Random());这将给您您想要的.在此示例中,一个由256位组成的BigInteger.
which will give you what you want. In this example, a BigInteger consisting of 256 bits.
更多推荐
生成非常大的随机数Java
发布评论