118535Sralph /* 222973Skre * Copyright (c) 1980 Regents of the University of California. 322973Skre * All rights reserved. The Berkeley software License Agreement 422973Skre * specifies the terms and conditions for redistribution. 518535Sralph * 6*41869Sbostic * @(#)random_.c 5.4 05/13/90 722979Skre * 818535Sralph * Routines to return random values 918535Sralph * 1018535Sralph * calling sequence: 1118535Sralph * double precision d, drandm 1218535Sralph * i = irandm(iflag) 1318535Sralph * x = random(iflag) 1418535Sralph * d = drandm(iflag) 1518535Sralph * where: 1618535Sralph * If arg is nonzero, generator is restarted and value is returned. 1718535Sralph * If arg is 0, next value is returned. 1818535Sralph * Integer values will range from 0 thru 2147483647 (see random(3)). 1918535Sralph * Real values will range from 0.0 thru 1.0 . 2018535Sralph */ 2118535Sralph 22*41869Sbostic #if defined(vax) || defined(tahoe) || defined(hp300) 2318535Sralph #define RANDMAX 2147483647 2429933Ssam #else vax || tahoe 2518535Sralph UNKNOWN MACHINE! 2629933Ssam #endif vax || tahoe 2718535Sralph 2818535Sralph long irandm_(iarg) 2918535Sralph long *iarg; 3018535Sralph { 3118535Sralph if (*iarg) srandom((int)*iarg); 3218535Sralph return( random() ); 3318535Sralph } 3418535Sralph 3518535Sralph float random_(iarg) 3618535Sralph long *iarg; 3718535Sralph { 3818535Sralph if (*iarg) srandom((int)*iarg); 3918535Sralph return( (float)(random())/(float)RANDMAX ); 4018535Sralph } 4118535Sralph 4218535Sralph double drandm_(iarg) 4318535Sralph long *iarg; 4418535Sralph { 4518535Sralph if (*iarg) srandom((int)*iarg); 4618535Sralph return( (double)(random())/(double)RANDMAX ); 4718535Sralph } 48