LCG-linear congruential generator
Source | m | a | c | rand() / Random(L)的种子位 |
Numerical Recipes | 2^32 | 1664525 | 1013904223 | |
Borland C/C++ | 2^32 | 22695477 | 1 | 位30..16 in rand(), 30..0 in lrand() |
glibc (used by GCC) | 2^32 | 1103515245 | 12345 | 位30..0 |
ANSI C: Watcom, Digital Mars, CodeWarrior, IBM VisualAge C/C++ | 2^32 | 1103515245 | 12345 | 位30..16 |
Borland Delphi, Virtual Pascal | 2^32 | 134775813 | 1 | 位63..32 of (seed * L) |
Microsoft Visual/Quick C/C++ | 2^32 | 214013 | 2531011 | 位30..16 |
Apple CarbonLib | 2^31-1 | 16807 | 0 | 见Park–Miller随机数发生器 |
int __cdecl rand (
void
)
{
_ptiddata ptd = _getptd();
return( ((ptd->_holdrand = ptd->_holdrand * 214013L
+ 2531011L) >> 16) & 0x7fff );
}