tfrand.c - plan9port - [fork] Plan 9 from user space
HTML git clone git://src.adamsgaard.dk/plan9port
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
tfrand.c (212B)
---
1 #include <u.h>
2 #include <libc.h>
3
4 #define MASK 0x7fffffffL
5 #define NORM (1.0/(1.0+MASK))
6
7 double
8 p9frand(void)
9 {
10 double x;
11
12 do {
13 x = lrand() * NORM;
14 x = (x + lrand()) * NORM;
15 } while(x >= 1);
16 return x;
17 }