This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/11307] New: srand() same seed different rand() sequence
- From: "reydecopas at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 22 Feb 2010 10:56:46 -0000
- Subject: [Bug libc/11307] New: srand() same seed different rand() sequence
- Reply-to: sourceware-bugzilla at sourceware dot org
when seeding srand with a value higher than MAX int (srand admits unsigned) the
sequence is different.
Seeding with an int value works fine...
Debian Lenny
/lib/libc-2.7.so
uname -a
Linux 2.6.26-2-amd64 #1 SMP Thu Feb 11 00:59:32 UTC 2010 x86_64 GNU/Linux
./random
1844858204 676293126 395948029
Ubuntu 9.10
/lib/libc-2.10.1.so
Linux 2.6.31-19-generic #56-Ubuntu SMP Thu Jan 28 02:39:34 UTC 2010 x86_64
GNU/Linux
./random
541782857 1046720792 1006023958
///random.c
#include <stdio.h>
#include <time.h>
int main()
{
srand((unsigned int )3147483646);
/*
Output random values.
*/
printf("%d %d %d\n", rand(),rand(),rand());
return 0;
}
--
Summary: srand() same seed different rand() sequence
Product: glibc
Version: 2.10
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: reydecopas at gmail dot com
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=11307
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.