Subject: lib/476: rand48.3 manual page error over lrand48 and mrand48
To: None <gnats-admin@sun-lamp.cs.berkeley.edu>
From: Douglas Thomas Crosher <dtc@scrooge.ee.swin.oz.au>
List: netbsd-bugs
Date: 09/14/1994 10:05:08
>Number: 476
>Category: lib
>Synopsis: rand48 manual page inconsistent with operation of lrand48 and mrand48
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: gnats-admin (Library Bug People)
>State: open
>Class: doc-bug
>Submitter-Id: net
>Arrival-Date: Wed Sep 14 10:05:07 1994
>Originator: Douglas Crosher
>Organization:
Swinburne University of technology
>Release:
>Environment:
System: NetBSD 1.0_BETA : Wed Aug 10 1994
>Description:
>How-To-Repeat:
Read the manual page for rand48, eg. man rand48
Note:
lrand48() and nrand48() return values of type long in the range [-2**31,
2**31-1]. The high-order (32) bits of r(n+1) are loaded into the returned
value.
mrand48() and jrand48() return values of type long in the range [0,
2**31-1]. The high-order (31) bits of r(n+1) are loaded into the lower
bits of the returned value, with the topmost (sign) bit set to zero.
Now run the following program:
-=-=-=-
#include <stdlib.h>
#include <stdio.h>
main(){
srand48(123456);
for (;;)
printf("%9x, %9x \n",lrand48(), mrand48());
}
-=-=-=-
Output:
55caefe0, f0ce381c
1a764ab1, a1b9c755
24eb7a12, e2d12e1
7eb5b0ce, 38e1ce13
7b4010d4, 8bd86ab5
305f1e5b, 45cdafd0
3be407c, 67653957
280d5386, f80c314
15d75ba1, a8c6de47
Note that lrand48 returns a 31 bit number and mrand48 returns a 32 bit
number, this is consistent with other machines I have tried but
inconsistent with the manual page which describes the opposite
behavior.
>Fix:
Swap the definitions of lrand48 and mrand48 in the manual page
lib/stdlib/rand48.3
>Audit-Trail:
>Unformatted: