• Advertisement

Archived

This topic is now archived and is closed to further replies.

generate random float values?

This topic is 5626 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
#define RANDOM_FLOAT(min, max) (((float)rand() / (float)RAND_MAX) * ((max) - (min)) + (min))

will work for any 2 floats. IE

RANDOM_FLOAT(-m, m)

EDIT- Added more parentheses

[edited by - Neosmyle on November 30, 2002 12:10:45 AM]

Share this post


Link to post
Share on other sites

  • Advertisement