In java, it's easy to find random number using Random() in a range.
Below is a method I've tried to do that.
public int rand(int min, int max){
Random rands = new Random();
int numRand = rands.nextInt(max-min) + min;
return numRand;
}
But, it's in integer which has 2,147,483,647 as maximum values.
Then, I need to compute some values that has large number.
Let's say the large number is 5234960860151076037807790832396537967963815240976924943830782457906435372625549206966897650382309539933354611312768681026528740101
It contains 130 characters of number. It can't be stored in integer, even in double. But, I need to find large random number like that.
So, I found the way to random large number with using BigInteger.
At here, the random number just for n-digit.
At here, the random number from 0 to n. It's similar with this.
At here, the random number from 1 to 8180385048
.
So far, I found them useful. But I'm still confusing how to know whether the minimum number is 0
or 1
or 123456712312
.
I want to generate random number using BigInteger from minimum to maximum values, such as from 123456712312
to 12345678910213212312312312312312
.
So, how can I find random number from that range (from 123456712312
to 12345678910213212312312312312312
)?