xref: /original-bsd/games/trek/ranf.c (revision 89a39cb6)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)ranf.c	5.4 (Berkeley) 06/01/90";
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