Any ideas?
Printable View
Any ideas?
Just an idea:
float f=rand()/100.0;
This works. I just wrote it now so it isn't the best, plus it is kinda expensive.
[edit]Code:#include <iostream>
#include <cstdlib>
#include <math.h>
#include <time.h>
int main(void) {
using namespace std;
srand(time(NULL));
float r;
int i;
for(;;) {
i = rand();
r = (i-sqrtf(i))/10000;
cout << r << endl;
}
return 0;
}
stupid smilies...
[/edit]
Just make a random integer then devide it by another number.
Then you can store it in a float or double...