首页 > 代码库 > 随机函数

随机函数

public static int Random(int min, int max)
{
if (min >= max)
return min;

int diff = max - min;
int ran = (int)Random();
ran = ran % (diff + 1);
return min + ran;
}

public static uint Random()
{
nextRandomSeed = (nextRandomSeed * 214013 + 2531011) % 2147483647;
return (nextRandomSeed >> 1) & 0xffff;
}

随机函数