xref: /csrg-svn/games/trek/ranf.c (revision 60859)
121289Sdist /*
2*60859Sbostic  * Copyright (c) 1980, 1993
3*60859Sbostic  *	The Regents of the University of California.  All rights reserved.
434205Sbostic  *
542606Sbostic  * %sccs.include.redist.c%
621289Sdist  */
721289Sdist 
811690Smckusick #ifndef lint
9*60859Sbostic static char sccsid[] = "@(#)ranf.c	8.1 (Berkeley) 05/31/93";
1034205Sbostic #endif /* not lint */
1111690Smckusick 
1212738Slayer # include	<stdio.h>
1312738Slayer 
ranf(max)1411690Smckusick ranf(max)
1511690Smckusick int	max;
1611690Smckusick {
1711690Smckusick 	register int	t;
1811690Smckusick 
1911690Smckusick 	if (max <= 0)
2011690Smckusick 		return (0);
2111690Smckusick 	t = rand() >> 5;
2211690Smckusick 	return (t % max);
2311690Smckusick }
2411690Smckusick 
2511690Smckusick 
franf()2611690Smckusick double franf()
2711690Smckusick {
2811690Smckusick 	double		t;
2911690Smckusick 	t = rand() & 077777;
3011690Smckusick 	return (t / 32767.0);
3111690Smckusick }
32