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

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

Post by <Use-Author-Address-Heade » Wed, 02 Dec 1998 04:00:00



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);
  }

Quote:}

 
 
 

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

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);
  }

2. Cyrix 5x86 - Worth the upgrade?

3. Need to run 32-bit instead of 64-bit on Solaris

4. login troubles

5. Solaris 9 installed with 32 & 64 bit supports but boots in 32 bit mode

6. Can't copy kernel into place

7. 32-bit Core files on 64-bit Sysetm

8. xconsole

9. 64-bit Solaris 7: wasn't Solaris 2.6 also 32-bit?

10. 64-bit to 32-bit OS change

11. REQUEST: 64-bit integer math on 32-bit processor

12. 64-bit or 32-bit?

13. Is it 64-bit or 32-bit?