Returns the next pseudorandom, uniformly distributed {@code float}value between {@code 0.0} and {@code 1.0} from this randomnumber generator's sequence.
The general contract of {@code nextFloat} is that one{@code float} value, chosen (approximately) uniformly from therange {@code 0.0f} (inclusive) to {@code 1.0f} (exclusive), ispseudorandomly generated and returned. All 224 possible {@code float} valuesof the form m x 2-24, where m is a positive integer less than 224 , are produced with (approximately) equal probability.
The method {@code nextFloat} is implemented by class {@code Random}as if by:
{@code}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 of randomly chosen bits, then the algorithm shown would choose {@code float}values from the stated range with perfect uniformity.
[In early versions of Java, the result was incorrectly calculated as:
{@code 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.]
@return the next pseudorandom, uniformly distributed {@code float}value between {@code 0.0} and {@code 1.0} from thisrandom number generator's sequence