xref: /original-bsd/games/trek/ranf.c (revision c95cd016)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that this notice is preserved and that due credit is given
7  * to the University of California at Berkeley. The name of the University
8  * may not be used to endorse or promote products derived from this
9  * software without specific prior written permission. This software
10  * is provided ``as is'' without express or implied warranty.
11  */
12 
13 #ifndef lint
14 static char sccsid[] = "@(#)ranf.c	5.2 (Berkeley) 05/05/88";
15 #endif /* not lint */
16 
17 # include	<stdio.h>
18 
19 ranf(max)
20 int	max;
21 {
22 	register int	t;
23 
24 	if (max <= 0)
25 		return (0);
26 	t = rand() >> 5;
27 	return (t % max);
28 }
29 
30 
31 double franf()
32 {
33 	double		t;
34 	t = rand() & 077777;
35 	return (t / 32767.0);
36 }
37