, rand() [0,RAND_MAX] RAND_MAX, , 32767.
u=(double)rand();
d=(double)RAND_MAX;
double div= u/d;
double res=div*interval_range;
, RAND_MAX interval_range. . , RAND_MAX, , , rand(), ( rand() , ). - , ( ). :

"", , ( , std_dev, ..), .
:
int main{
int o=RAND_MAX;
std::map<int,int> m1;
int min=0,max=999;
for (int i=0; i<1000*9994240; ++i){
int r=rand();
if(r<=max){
m1[r]++;
}
}
for (auto & i : m1)
std::cout << i.first << " : " << i.second << '\n';
}
Result: 0: 42637 1: 42716 2: 42590 3: 42993 4: 42936 5: 42965 6: 42941 7: 42705 8: 42944 9: 42707 10: 42860 11: 43012 12: 42793 // ... 995: 42861 996 : 42911 997: 42865 998: 42877 999: 43159
you can achieve the desired result in any domain this way:
#include <iostream>
#include <random>
int main()
{
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(0, 1000);
for (int n=0; n<1000; ++n)
std::cout << dis(gen) << ' ';
std::cout << '\n';
}
however, in this case, you really should use boost:
#include <iostream>
#include "boost/random.hpp"
#include "boost/generator_iterator.hpp"
using namespace std;
int main() {
typedef boost::mt19937 RNGType;
RNGType rng;
boost::uniform_int<> zero_to_n( 0, 999 );
boost::variate_generator< RNGType, boost::uniform_int<> >
dice(rng, zero_to_n);
int n = dice();
}