views:

65

answers:

2

I am trying to generate random integers over the range (-32768, 32767) of the primitive data type short. The java Random object only generates positive numbers. How would I go about randomly creating numbers on that interval? Thanks.

+5  A: 

You random on (0, 32767+32768) then subtract by 32768

pinichi
+2  A: 

Generate numbers between 0 and 65535 then just subtract 32768

jcopenha