1*18535Sralph /* 2*18535Sralph char id_random[] = "@(#)random_.c 1.1"; 3*18535Sralph * 4*18535Sralph * Routines to return random values 5*18535Sralph * 6*18535Sralph * calling sequence: 7*18535Sralph * double precision d, drandm 8*18535Sralph * i = irandm(iflag) 9*18535Sralph * x = random(iflag) 10*18535Sralph * d = drandm(iflag) 11*18535Sralph * where: 12*18535Sralph * If arg is nonzero, generator is restarted and value is returned. 13*18535Sralph * If arg is 0, next value is returned. 14*18535Sralph * Integer values will range from 0 thru 2147483647 (see random(3)). 15*18535Sralph * Real values will range from 0.0 thru 1.0 . 16*18535Sralph */ 17*18535Sralph 18*18535Sralph #if vax 19*18535Sralph #define RANDMAX 2147483647 20*18535Sralph #else vax 21*18535Sralph UNKNOWN MACHINE! 22*18535Sralph #endif vax 23*18535Sralph 24*18535Sralph long irandm_(iarg) 25*18535Sralph long *iarg; 26*18535Sralph { 27*18535Sralph if (*iarg) srandom((int)*iarg); 28*18535Sralph return( random() ); 29*18535Sralph } 30*18535Sralph 31*18535Sralph float random_(iarg) 32*18535Sralph long *iarg; 33*18535Sralph { 34*18535Sralph if (*iarg) srandom((int)*iarg); 35*18535Sralph return( (float)(random())/(float)RANDMAX ); 36*18535Sralph } 37*18535Sralph 38*18535Sralph double drandm_(iarg) 39*18535Sralph long *iarg; 40*18535Sralph { 41*18535Sralph if (*iarg) srandom((int)*iarg); 42*18535Sralph return( (double)(random())/(double)RANDMAX ); 43*18535Sralph } 44