written by Eric Allman; add Berkeley header
[unix-history] / usr / src / games / trek / ranf.c
CommitLineData
b6f0a7e4
DF
1/*
2 * Copyright (c) 1980 Regents of the University of California.
e9fb6bea
KB
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.
b6f0a7e4
DF
11 */
12
db247e8f 13#ifndef lint
e9fb6bea
KB
14static char sccsid[] = "@(#)ranf.c 5.2 (Berkeley) %G%";
15#endif /* not lint */
db247e8f 16
06d69904
KL
17# include <stdio.h>
18
db247e8f
KM
19ranf(max)
20int 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
31double franf()
32{
33 double t;
34 t = rand() & 077777;
35 return (t / 32767.0);
36}