I want to generate a random number that falls in the range 50 to 100 and -50 to -100 I am now using the following formula to achieve this:
(50 + (rand() % 50)) * ((rand() % 2) * 2 - 1)
where
(50 + (rand() % 50)) gives me a random number in the range 50 to 100 and
((rand() % 2) * 2 - 1) gives me +/- 1
I used two random generation calls, but Is it possible using just 1 random function call ? Are there any other better alternatives to the above formula ?
