dimanche 10 janvier 2021

Generating a random number between 0.5 and 1.5 in bash [duplicate]

I need random numbers to three decimal places like:

0.624, 1.035, 0.869, 1.324

What I am using is:

"0.$(($RANDOM%1000+500))"

However, in this case, all the values less than 1 are correct (i.e. 0.917,0.917,0.917,0.855), but the values greater than 1 are incorrect (i.e 0.1195,0.14340.1434) as I append 0. At the beginning of the random number produced.

Thanks.




Aucun commentaire:

Enregistrer un commentaire