Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

rand() warmup

Name: Anonymous 2012-01-20 16:28

void init_random() {
    clock_t start = clock();
    int i = 0;
    while (clock() - start == 0) {
        i++;
    }
    srand(time(0) + i);
}


17±3 ms
Is it okay?

Name: Anonymous 2012-01-20 17:15

>>2
I could rely on uninitialized memory too and/or memory location.
void init_random() {
    long seed;
    srand(time(0) + seed + (long)&seed);
}


>>3
It isn't portable.
Anyway, does portability matter? If not, I would use rdtsc.

>>4
time() returns seconds. Processes starting in the same second get the same seeds.

>>5
;__;

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List