有一个 CmoTime 变量,其中不断生成 0,尽管它似乎不是CmoTime = TimeGenerator(true, OrderInterval, Precision);
(例如,对于这样的数字 OrderInterval=0.06,Precision=0.01)。这是 TimeGenerator 本身 (Interval=0.01, Precition(Tochnost)=100)
private double TimeGenerator(bool FirstOrder, double Tochnost, double Interval)
{
double NewTime;
int GenerationInterval = (int)(Interval * Precition(Tochnost) + 1);
// только если это не первая заявка
if (!FirstOrder)
{
// исключение генерации нуля => повторяющееся время
do
{
NewTime = (double)(rand.Next() % GenerationInterval) / Precition(Tochnost);
} while (NewTime == 0);
}
else NewTime = (double)(rand.Next() % GenerationInterval) / Precition(Tochnost);
return Math.Round(NewTime, ChisloZnakov(Tochnost));
}
您的函数
Precition
返回 null。开始计算后,我的 Program 函数停止工作,Precition
无法返回零。但是你把它注释掉了,所以它仍然返回 null。throw
因为它
Precition
返回零,所以它GenerationInterval
等于一。因为它
GenerationInterval
等于一,rand.Next() % GenerationInterval
所以它将为零。因此,
NewTime = 0/0;
“不是一个数字”。