This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
rand() man-page ambiguous or bug in glibc?
- From: Folkert van Heusden <folkert at vanheusden dot com>
- To: libc-help at sourceware dot org
- Cc: udovdh at xs4all dot nl
- Date: Tue, 29 Apr 2008 11:26:15 +0200
- Subject: rand() man-page ambiguous or bug in glibc?
- Organization: www.unixexpert.nl
- Reply-by: Sun Apr 27 23:40:14 CEST 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