本文整理汇总了C#中IRandom.NextLong方法的典型用法代码示例。如果您正苦于以下问题:C# IRandom.NextLong方法的具体用法?C# IRandom.NextLong怎么用?C# IRandom.NextLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRandom
的用法示例。
在下文中一共展示了IRandom.NextLong方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RandRangeTest
private void RandRangeTest(IRandom Rand, int Iterations = 1000)
{
byte[] data;
int x;
long y;
int min, max;
min = Rand.Next(33);
max = Rand.Next(34, 111);
for (int i = 0; i < Iterations; i++)
data = Rand.GetBytes(i * 10);
for (int i = 1; i < Iterations; i++)
{
x = Rand.Next(i * min, i * max);
if (x > i * max)
throw new Exception(Rand.Name + ":Next returned a value above of the expected range.");
if (x < i * min)
throw new Exception(Rand.Name + ":Next returned a value below of the expected range.");
y = Rand.NextLong(i * min, i * max);
if (y > i * max)
throw new Exception(Rand.Name + ":NextLong returned a value above of the expected range.");
if (y < i * min)
throw new Exception(Rand.Name + ":NextLong returned a value below of the expected range.");
}
}
示例2: GF2nONBElement
/// <summary>
/// Construct a random element over the field <c>gf2n</c>, using the specified source of randomness
/// </summary>
///
/// <param name="Gf2n">The field</param>
/// <param name="SecRnd">The source of randomness</param>
public GF2nONBElement(GF2nONBField Gf2n, IRandom SecRnd)
{
mField = Gf2n;
mDegree = mField.Degree;
_mLength = Gf2n.GetONBLength();
_mBit = Gf2n.GetONBBit();
_mPol = new long[_mLength];
if (_mLength > 1)
{
for (int j = 0; j < _mLength - 1; j++)
_mPol[j] = SecRnd.NextLong(); //ju next long?
long last = SecRnd.Next();
_mPol[_mLength - 1] = IntUtils.URShift(last, (MAXLONG - _mBit));
}
else
{
_mPol[0] = SecRnd.NextLong();
_mPol[0] = IntUtils.URShift(_mPol[0], (MAXLONG - _mBit));
}
}