mardi 17 mai 2016

How to get a random float value between 0 and 100 [duplicate]

This question already has an answer here:

I need a random float value between 0 and 100.

Easiest way to do this would be

Random generator = new Random();
float x = generator.nextFloat() * 100;

There's only a little Problem. nextFloat() returns values in interval [0,1), but I need values from [0,1].

Anyone an idea how to solve it?

Thanks




Aucun commentaire:

Enregistrer un commentaire