rand() man-page ambiguous or bug in glibc?

Folkert van Heusden folkert@vanheusden.com
Tue Apr 29 09:26:00 GMT 2008


Hi,

The man-page says:
	The rand() function returns a pseudo-random integer between 0
	and RAND_MAX.
"Between" says me that neither 0 or RAND_MAX should be returned but a
simple test-program tells me otherwise.

#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]){for(;;){long long int dummy=rand(); if
(dummy == 0 || dummy == RAND_MAX)printf("value is %d\n", dummy);} return
0;}

So what is it?


Folkert van Heusden

-- 
To MultiTail einai ena polymorfiko ergaleio gia ta logfiles kai tin
eksodo twn entolwn. Prosferei: filtrarisma, xrwmatismo, sygxwneysi,
diaforetikes provoles. http://www.vanheusden.com/multitail/
----------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com



More information about the Libc-help mailing list