How do i make a random number using rand between
0 and 1
like .45
ect.
Thanks
I need this ASAP!!
Printable View
How do i make a random number using rand between
0 and 1
like .45
ect.
Thanks
I need this ASAP!!
this should work:
That's really all there is to it. rand() returns an integer between 0 and RAND_MAX (which is 32767) so you can get pretty much any kind of random number from it.PHP Code:// couple of includes you need
#include <stdlib.h>
#include <time.h>
// the random number code
srand( (unsigned)time( NULL ) );
float randomnum = (float)rand() / (float)RAND_MAX; // RAND_MAX = 32767
// now use randomnum however you like