title: How do you generate a random number with equal probability using Math.random() in Java
body: <p>I'm currently working through an exercise where I am required to generate a random number which can be one of 4 values. (note I'm only allowed to use Math.random())</p>
  
  <p>0
  1
  2
  or 3</p>
  
  <p>Currently I am using this: <code>randno = (int) (Math.random()*4); // range 0-3</code> </p>
  
  <p>However, the outcome MUST have equal probability. My tests so far (although the method is lacking) shows that 3 occurs far less than the other numbers. </p>
  
  <p>Is this coincidence? Or does my generator not have equal probability.</p>
  
  <p>Thanks!</p>