random integer



I was just wondering what the best way to generate a uniformly
distributed random integer between 0 and x is.

Usually, you can't just do rand()%(x+1). For instance, if you want a
number between 0 and 31999, you can't just do rand()%32000 since
0-767 will be twice as likely.

.