生成非常大的随机数Java

编程入门 行业动态 更新时间:2024-10-14 16:24:20
本文介绍了生成非常大的随机数Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我们如何在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

本文发布于:2023-11-29 12:23:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1646383.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:随机数   非常大   Java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!