add numerical recipes library
This commit is contained in:
22
lib/nr/ansi/recipes/irbit2.c
Normal file
22
lib/nr/ansi/recipes/irbit2.c
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
#define IB1 1
|
||||
#define IB2 2
|
||||
#define IB5 16
|
||||
#define IB18 131072
|
||||
#define MASK (IB1+IB2+IB5)
|
||||
|
||||
int irbit2(unsigned long *iseed)
|
||||
{
|
||||
if (*iseed & IB18) {
|
||||
*iseed=((*iseed ^ MASK) << 1) | IB1;
|
||||
return 1;
|
||||
} else {
|
||||
*iseed <<= 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#undef MASK
|
||||
#undef IB18
|
||||
#undef IB5
|
||||
#undef IB2
|
||||
#undef IB1
|
||||
Reference in New Issue
Block a user