Subject: lrand48/mrand48 operation diff. their man page
To: None <current-users@sun-lamp.cs.berkeley.edu>
From: Douglas Crosher <dtc@stan.xx.swin.OZ.AU>
List: current-users
Date: 08/19/1994 01:24:31
I've noticed what I think is an inconsistancy between the operation of
the functions lrand48() and mrand48() , and their description in the
manual page. This is on NetBSD 1.0_BETA binary snapshot of Aug 2.
Details follow:

Running the following program shows that lrand48 produdes a 31 bit
random number, and mrand48 produces a 32 bit random number:

-=-=-=-=-
#include <stdlib.h>
#include <stdio.h>

main(){
srand48(123456);

for (;;)
printf("%9x, %9x\n",lrand48(),mrand48());

}
-=-=-=-=-
 14414d5b,   6cf5875 
 40136939,  b91b6506 
 53c4aa21,  f5f02665 
 454b049e,  e68ec29a 
 211bbda6,  2316e45b 
  258e250,  f852cf50 
 6472af94,  52c282e9 

-=-=-=-=-

The manual page reads:

     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.

Can anyone confirm the correct operation?

Regards
Douglas Crosher

------------------------------------------------------------------------------