This is brrand.c in view mode; [Download] [Up]
main()
{
float a[100];
int j,k,i;
j=100;
srrand(22);
brrand(100.,a,j);
for(i=0; i<100; i++) printf(" %f\n",a[i]);
}
/* a modification of unix rand() to return floating point values between
+ and - 1. */
static long randx = 1;
srrand(x)
unsigned x;
{
randx = x;
}
brrand(amp,a,j)
float *a,amp;
{
int k;
for(k=0; k<j; k++) {
int i = ((randx = randx*1103515245 + 12345)>>16) & 077777;
*a++ = amp * ((float)i/16384. - 1.);
}
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.