public float nextFloat(){
  return (next(24) / 16777216f);
}

public float nextFloat ( ) { return ( next ( 24 ) / 16777216f ) ; }
returns the next pseudorandom , uniformly distributed float value between 0 . 0 and 1 . 0 from this random number generator ' s sequence . the general contract of nextfloat is that one float value , chosen ( approximately ) uniformly from the range 0 . 0f ( inclusive ) to 1 . 0f ( exclusive ) , is pseudorandomly generated and returned . all 224 possible float values of the form mx & nbsp2 - 24 , where m is a positive integer less than 224 , are produced with ( approximately ) equal probability . the method nextfloat is implemented by class random as follows : public float nextfloat ( ) { return next ( 24 ) / ( ( float ) ( 1 < < 24 ) ) ; } the hedge " approximately " is used in the foregoing description only because the next method is only approximately an unbiased source of independently chosen bits . if it were a perfect source or randomly chosen bits , then the algorithm shown would choose float values from the stated range with perfect uniformity . [ in early versions of java , the result was incorrectly calculated as : return next ( 30 ) / ( ( float ) ( 1 < < 30 ) ) ; this might seem to be equivalent , if not better , but in fact it introduced a slight nonuniformity because of the bias in the rounding of floating - point numbers : it was slightly more likely that the low - order bit of the significand would be 0 than that it would be 1 . ]
