Im trying to generate random numbers between -32767 and +32767, some help as to where im going wrong would be helpful as this code generates only negative numbers
The problem could be that RAND_MAX is too small. If RAND_MAX is 32767 (smallest guaranteed value) then you will only get negative numbers if you use the formula posted by Darkmaster.
You could combine the values from two calls to rand() to make a bigger random number. (rand() << 15) ^ rand() will return a value between 0 and at least 1073741823.
Hi peter87, i didnt really understand what ur trying to say, if you could elaborate it would be better as i cnt understand understand what ur saying i should try doing