Take the 2-minute tour ×

As the title suggest, would hope to generate a random float in the range between 0.3 < x < 0.7.

I currently using while loop to check a random float whether its in that range. I was wondering whether there is a better method to do this.


share|improve this question
add comment

1 Answer

0.3 + random-float 0.4 will give you 0.3 <= x < 0.7.

If you really don't want 0.3, I guess you can always loop that one out. I'm not sure if there is a better way.

share|improve this answer
re: the question of 0.3 exactly coming up, see ccl.northwestern.edu/netlogo/docs/faq.html#onepointoh –  Seth Tisue Mar 26 '12 at 12:40
add comment

Your Answer


