c语言如何生成(0,1)之间均匀分布的随机数?

c语言或者c++如何生成在(0,1)之间间隔为0.125均匀分布的随机数,等概率生成随机数?

那么你只要生成0-8的随机整数,然后除以8即可。

#include <stdio.h>
#include <stdlib.h>
#include <time.h> 

int main()
{
    int x,num;
    srand(time( NULL )); 
    x =1 + (rand()%8);

    printf("%f",x/8.0);

    return 0;
}