[go: up one dir, main page]

Menu

[r377]: / fish_shark / ran4.c  Maximize  Restore  History

Download this file

26 lines (24 with data), 643 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
float ran4(long *idum)
{
void psdes(unsigned long *lword, unsigned long *irword);
unsigned long irword,itemp,lword;
static long idums = 0;
#if defined(vax) || defined(_vax_) || defined(__vax__) || defined(VAX)
static unsigned long jflone = 0x00004080;
static unsigned long jflmsk = 0xffff007f;
#else
static unsigned long jflone = 0x3f800000;
static unsigned long jflmsk = 0x007fffff;
#endif
if (*idum < 0) {
idums = -(*idum);
*idum=1;
}
irword=(*idum);
lword=idums;
psdes(&lword,&irword);
itemp=jflone | (jflmsk & irword);
++(*idum);
return (*(float *)&itemp)-1.0;
}
/* (C) Copr. 1986-92 Numerical Recipes Software )&%. */