This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug manual/7003] New: description of maximum value of random and random_r
- From: "bruno at clisp dot org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 4 Nov 2008 11:28:15 -0000
- Subject: [Bug manual/7003] New: description of maximum value of random and random_r
- Reply-to: sourceware-bugzilla at sourceware dot org
The description of the function random (and random_r later on that page says that
"The value returned ranges from 0 to RAND_MAX."
POSIX <http://www.opengroup.org/susv3/functions/random.html> says that the
value ranges from 0 to 2^{31}-1. So glibc's statement is right for glibc systems,
where RAND_MAX == 2^{31}-1. But it tricks programmers into writing code like
double from_0_to_1 = (double) random () / ((double) RAND_MAX + 1.0);
where
double from_0_to_1 = (double) random () / 2147483648.0;
would be correctly portable to other POSIX systems.
Find attached a doc fix.
--
Summary: description of maximum value of random and random_r
Product: glibc
Version: 2.8
Status: NEW
Severity: normal
Priority: P2
Component: manual
AssignedTo: roland at gnu dot org
ReportedBy: bruno at clisp dot org
CC: glibc-bugs at sources dot redhat dot com
GCC build triplet: i686-suse-linux-gnu
GCC host triplet: i686-suse-linux-gnu
GCC target triplet: i686-suse-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=7003
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.