java BigInteger random number in a minimum and maximum range -


in java, it's easy find random number using random() in range.

below method i've tried 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 has 2,147,483,647 maximum values.

then, need compute values has large number.

let's large number 5234960860151076037807790832396537967963815240976924943830782457906435372625549206966897650382309539933354611312768681026528740101

it contains 130 characters of number. can't stored in integer, in double. but, need find large random number that.

so, found way random large number using biginteger.

at here, random number n-digit.

at here, random number 0 n. it's similar this.

at here, random number 1 8180385048.

so far, found them useful. i'm still confusing how know whether minimum number 0 or 1 or 123456712312.

i want generate random number using biginteger minimum maximum values, such 123456712312 12345678910213212312312312312312.

so, how can find random number range (from 123456712312 12345678910213212312312312312312)?


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -