qkslvrwolf
Programmer
Hi, I'm trying to generate some random floats, preferablly with a fairly involved post decimal presence, if you take my meaning. Currently, I've tried this...#include <stdlib.h>
#include <time.h>
int main()
{
float check;
int i;
srand((unsigned )time( NULL ));
for (i = 0; i < 20; i++)
{
check = rand()/rand();
printf("%f\n", check);
}
}
But this produces mainly produces 1's and 0's, with a few other basically integer values thrown in. The way I understood this process, this should be creating a psuedorandom number from 0 to 32 thousand something, but then I should be getting some decent floats, not all integers, shouldn't i?
#include <time.h>
int main()
{
float check;
int i;
srand((unsigned )time( NULL ));
for (i = 0; i < 20; i++)
{
check = rand()/rand();
printf("%f\n", check);
}
}
But this produces mainly produces 1's and 0's, with a few other basically integer values thrown in. The way I understood this process, this should be creating a psuedorandom number from 0 to 32 thousand something, but then I should be getting some decent floats, not all integers, shouldn't i?