Please do not dismiss this as a duplicate of: How to generate random positive and negative numbers in java
I need to use a Random number generator with a seed. So, I used the java.util.Random class with a constructor that takes a seed.
Random random = new Random(System.currentTimeMillis());
Then I used the solution given in the above thread
int randomValue = random.nextInt(max - min + 1) + min;
However, the problem with the above solution is that if min is a large negative number and max is a large positive number , then (max - min + 1) would result in overflow.
There should be a better solution out there. Can anyone please point me to it.
Thank you!