From: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
To: John Marshall <John.W.Marshall@glasgow.ac.uk>
Cc: mtk.manpages@gmail.com, linux-man@vger.kernel.org,
walter harms <wharms@bfs.de>
Subject: Re: [patch] random.3: wfix: RAND_MAX is for rand(3)
Date: Mon, 8 Jun 2020 22:27:04 +0200 [thread overview]
Message-ID: <bec22479-dc29-cbaf-89d2-1fc95da2fcc2@gmail.com> (raw)
In-Reply-To: <20200608110416.GA21314@Johns-MacBook-Pro.local>
On 6/8/20 1:04 PM, John Marshall wrote:
> POSIX fixes random()'s range at 2^31-1; RAND_MAX may be smaller on some
> platforms (even though with glibc or musl on Linux they are the same).
> ---
>
> On Sat, Jun 06, 2020 at 12:45:58PM +0000, Walter Harms wrote:
>> that RAND_MAX is 2^31-1 in some cases does not matter. IMHO
>> it is wrong to mention RAND_MAX in the random page. it can
>> simply be replaced with (2**31-1)
>
> Thanks for confirming, Walter. I forgot to mention I was happy to
> provide a patch -- suggested fix in this git-format-patch message.
>
> John
>
> man3/random.3 | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/man3/random.3 b/man3/random.3
> index 76b076f42..e3550f802 100644
> --- a/man3/random.3
> +++ b/man3/random.3
> @@ -69,7 +69,7 @@ The
> function uses a nonlinear additive feedback random
> number generator employing a default table of size 31 long integers to
> return successive pseudo-random numbers in
> -the range from 0 to \fBRAND_MAX\fR.
> +the range from 0 to 2^31\ \-\ 1.
> The period of this random number generator is very large, approximately
> .IR "16\ *\ ((2^31)\ \-\ 1)" .
> .PP
> @@ -125,7 +125,9 @@ or be the result of a previous call of
> The
> .BR random ()
> function returns a value between 0 and
> -.BR RAND_MAX .
> +.BR INT32_MAX ,
> +i.e.,
> +.IR "(2^31)\ \-\ 1" .
> The
> .BR srandom ()
> function returns no value.
Hello John,
Thanks. I applied this patch. I also agree with Walter. There's no
real need to mention INT32_MAX, so I removed that piece.
Cheers,
Michael
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
prev parent reply other threads:[~2020-06-08 20:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-05 17:21 random(3) and RAND_MAX John Marshall
2020-06-06 12:45 ` AW: " Walter Harms
2020-06-08 11:04 ` [patch] random.3: wfix: RAND_MAX is for rand(3) John Marshall
2020-06-08 11:10 ` AW: " Walter Harms
2020-06-08 11:20 ` John Marshall
2020-06-08 11:21 ` AW: " Jakub Wilk
2020-06-08 12:50 ` AW: " Walter Harms
2020-06-08 20:27 ` Michael Kerrisk (man-pages) [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bec22479-dc29-cbaf-89d2-1fc95da2fcc2@gmail.com \
--to=mtk.manpages@gmail.com \
--cc=John.W.Marshall@glasgow.ac.uk \
--cc=linux-man@vger.kernel.org \
--cc=wharms@bfs.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.