Alex Rivera | Logout

Producing random float from negative to positive range?

Asked 2010-11-30T03:30:37.770
11

I am trying to produce a random float within the range -50.0 and 50.0 inclusively, using rand(). I've looked everywhere for an answer but it deals with ints and % operator.

Edit
Report

1 Answer

4
((float)rand())/RAND_MAX * 100.0 - 50.0
answered 2010-11-30T03:33:44.493

Your Answer