mrand48() returning 16-bit longs, instead of 32-bit

mrand48() returning 16-bit longs, instead of 32-bit

Post by Timothy Culve » Wed, 02 Dec 1998 04:00:00



I'm getting 16-bit signed integers from mrand48(), in contrast to the
man page, which says they should be 32-bit signed integers.  I do get
32-bit integers with gcc-2.7.2 on Solaris with the same program.

I don't know if the problem is egcs, libc, glibc, or Linux.

Anybody have any ideas?

Thanks,
Tim Culver

Linux:  RedHat 5.1 with updates
Compiler:  egcs-1.0.2-8
           libc-5.3.12-27
           glibc-2.0.7-19

Example program
---------------

#include <stdlib.h>
#include <math.h>

int main() {
  long a;
  double l;
  int i;
  srand48(1126);
  for (i=0; i<10; i++) {
    a = mrand48();
    l = log(fabs((double)a))/log(2.0);
    printf("%d\t%lf\n",a,l);
  }

Quote:}

 
 
 

1. mrand48() returning 17-bit longs, instead of 32-bit

I'm getting 17-bit signed integers from mrand48(), in defiance of the
man page, which says they should be 32-bit signed integers.

Am I missing something?

Thanks,
Tim Culver

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

Problem happens on these two machines:

Machine:  PC
OS:  RedHat 5.1 with updates
Compiler:  egcs-1.0.2-8
           libc-5.3.12-27
           glibc-2.0.7-19

Machine:  PC
OS:  RedHat 5.1 with updates
Compiler:  gcc-2.7.2.3-8
           libc-5.3.12-24
           glibc-2.0.7-19

Problem does not happen on this machine:

Machine: SPARCstation
OS:  Solaris
Compiler:  gcc-2.7.2 or Sun's cc

Example program
---------------

On the SPARCstation, the numbers in the second column are close to 31,
as they should be.  On the Linux boxes, they're close to 16.

#include <stdlib.h>
#include <math.h>

int main() {
  long a;
  double l;
  int i;
  srand48(1126);
  for (i=0; i<10; i++) {
    a = mrand48();
    l = log(fabs((double)a))/log(2.0);
    printf("%d\t%lf\n",a,l);
  }

2. SCSI Zip for linux

3. I need to run 16-bit executable on 32-bit OS

4. *** NEW WAY TO PROMOTE YOUR WEB YOURSELF ***

5. NIS+ nispasswd root

6. SpeedStar64 on 16-bit & 32-bit modes

7. execution RunCache

8. How to run a 16-bit executable on a 32-bit OS?

9. Can't use 16-bit, 32-bit modes

10. DMA : 32-bit physical address -> 16-bit segment/offset

11. difference between 16-bit & 32-bit OPERATING SYSTEMS

12. Calling 16-bit PM code from 32-bit PM Kernel Driver