aboutsummaryrefslogtreecommitdiff
path: root/src/lib9/frand.c
blob: 841f968524e13375628542adaad3d4efafa06345 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include	<u.h>
#include	<libc.h>

#define	MASK	0x7fffffffL
#define	NORM	(1.0/(1.0+MASK))

double
p9frand(void)
{
	double x;

	do {
		x = lrand() * NORM;
		x = (x + lrand()) * NORM;
	} while(x >= 1);
	return x;
}