for(int i=0; i<N; i++)
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
for rnd numbers in the range of a to b, do:
yours looks correct, but i would just use + instead of -- and - instead of +-
don't have a pc around to tedt it, so what excactly is your problem?
i tired that as well, it just outputs negative numbers, like not a single value is positive
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