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
You might try:
int n = rand() + rand() - RAND_MAX;
which should give a random number in the range
-RAND_MAX to +RAND_MAX
What you say is true but the random numbers will not have a uniform distribution. n is more likely to get values close to 0.
Last edited on
Unbiased scaling of random numbers is somewhat tricky.
MiiNiPaa's suggestion: +1