1 /* 2 * Copyright (c) 1980, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)ranf.c 8.1 (Berkeley) 05/31/93"; 10 #endif /* not lint */ 11 12 # include <stdio.h> 13 14 ranf(max) 15 int max; 16 { 17 register int t; 18 19 if (max <= 0) 20 return (0); 21 t = rand() >> 5; 22 return (t % max); 23 } 24 25 26 double franf() 27 { 28 double t; 29 t = rand() & 077777; 30 return (t / 32767.0); 31 } 32