modern syntax for inits. When ANSI cpp comes will need more work.
[unix-history] / usr / src / games / trek / ranf.c
CommitLineData
b6f0a7e4
DF
1/*
2 * Copyright (c) 1980 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6
db247e8f 7#ifndef lint
b6f0a7e4 8static char sccsid[] = "@(#)ranf.c 5.1 (Berkeley) %G%";
db247e8f
KM
9#endif not lint
10
06d69904
KL
11# include <stdio.h>
12
db247e8f
KM
13ranf(max)
14int max;
15{
16 register int t;
17
18 if (max <= 0)
19 return (0);
20 t = rand() >> 5;
21 return (t % max);
22}
23
24
25double franf()
26{
27 double t;
28 t = rand() & 077777;
29 return (t / 32767.0);
30}