Random Number Generator
Came across at work today a section of code.
public Long generateNumber(Long in, String start) {
java.util.Random generator = new Random();
int r = in.intValue();
while ( r <= in) {
r = generator.nextInt(in.intValue());
while (r > 1300)
r = r/132;
}
// Long l = 0L;
return Long.valueOf(r);
}
Now, there are a lot of approaches to generating random numbers. In fact, it's sort of one of the more difficult questions in computer science (true random vs. pseudorandom). If I were to venture a guess, I'd say that this is not one of them.
- Previous: What I Did and Didn't Do
- Next: Lime in the coconut