how can i generate negative random numbers

java.util.Random.nextInt returns just numbers bigger than zero, how can i get some integer numbers within -n up to n for example ?Regards,
[152 byte] By [d_rotha] at [2007-11-27 4:08:04]
# 1
Hmmmm.... if I have a number in the range 0..99 and I want to have a number in the range -50..+49, I wonder what I could do... :-)
jverda at 2007-7-12 9:13:24 > top of Java-index,Java Essentials,Java Programming...
# 2
random number from 0 - n then multiply by -1*edit* rest left to user to figure out
Aknibbsa at 2007-7-12 9:13:24 > top of Java-index,Java Essentials,Java Programming...
# 3
i think what aknibbs means, lol, is:random number from 0 - N, then SUBTRACT(nothing left for user to figure out)
TuringPesta at 2007-7-12 9:13:24 > top of Java-index,Java Essentials,Java Programming...
# 4
Well, there's the value of N, for starters ;-)
DrLaszloJamfa at 2007-7-12 9:13:24 > top of Java-index,Java Essentials,Java Programming...
# 5

> i think what aknibbs means, lol, is:

> random number from 0 - N, then SUBTRACT

> (nothing left for user to figure out)

there is for them to get from -n to 0 to +n

I wasn't sure if they were having a brain **** how to get a negative number out of the generator.

*Edit* When i first posted my answer I missed that they wanted from -n to +n so in hindsight my suggestion was not a good one at all - which leaves even more for the user to figure out.

Aknibbsa at 2007-7-12 9:13:24 > top of Java-index,Java Essentials,Java Programming...