1*47940Sbostic/*- 2*47940Sbostic * Copyright (c) 1980 The Regents of the University of California. 3*47940Sbostic * All rights reserved. 4*47940Sbostic * 5*47940Sbostic * %sccs.include.proprietary.c% 6*47940Sbostic */ 7*47940Sbostic 8*47940Sbostic#ifndef lint 9*47940Sbosticstatic char sccsid[] = "@(#)rand_.c.other 5.2 (Berkeley) 04/12/91"; 10*47940Sbostic#endif /* not lint */ 11*47940Sbostic 1247939Sbostic/* 1347939SbosticUniform random number generator. Code courtesy of Bob Morris. 1447939SbosticLinear congruential generator, suitable for 32 bit machines; 1547939Sbosticmultiplication is mod 2**31 1647939Sbostic*/ 1747939Sbostic 1847939Sbosticstatic long randx = 1; 1947939Sbostic 2047939Sbosticsrand_(x) /* subroutine to set seed */ 2147939Sbosticlong *x; 2247939Sbostic{ 2347939Sbosticrandx = *x; 2447939Sbostic} 2547939Sbostic 2647939Sbostic 2747939Sbostic 2847939Sbostic 2947939Sbosticdouble rand_() 3047939Sbostic{ 3147939Sbosticdouble ldexp(); 3247939Sbosticreturn(ldexp((double)(((randx = randx*1103515245 + 12345)>>7) & 077777777), -24)); 3347939Sbostic} 34