[9529] in Athena Bugs

home help back first fref pref prev next nref lref last post

IBM RS6000 7.3: Rand

daemon@ATHENA.MIT.EDU (ellis@Athena.MIT.EDU)
Wed Jul 1 10:46:52 1992

From: ellis@Athena.MIT.EDU
To: bugs@Athena.MIT.EDU
Date: Wed, 01 Jul 92 10:46:38 EDT

System name:		m37-332-4
Type and version:	POWER 7.3
Display type:		colorgda

What were you trying to do?
        Use the rand() function as documented.

What's wrong:
        The documentation on rand() says that compiling with -lbsd should
        cause the range of random numbers to change from 2^15-1 to 2^31-1. 
        The following example code should produce different results when
        compiled with -lbsd. However, when compiled, with and without -lbsd,
        no change occurs. The range of random numbers remains 0 to 2^15-1.

#include <stdlib.h>

main()
{
   int seed = -1;
   float y;
   int i;

   srand(seed);
   for(i=0; i<=100; i++)
   {
     y = rand();
     printf("i = %d y = %f \n", i,y);
   }
}


What should have happened:
        When compiled with -lbsd range of random numbers should be 0 to 2^31-1.

Please describe any relevant documentation references:
        Online info for rand() function

home help back first fref pref prev next nref lref last post