public long UniformLong(long maxExclusive)
{
if (maxExclusive < 0) {
throw new ArgumentException("maxExclusive (" + maxExclusive +
") is less than 0");
}
if (maxExclusive <= Int32.MaxValue) {
return this.UniformInt((int)maxExclusive);
}
long lb = 0;
long maxexc;
var b = new byte[8];
maxexc = (Int64.MaxValue / maxExclusive) * maxExclusive;
while (true) {
this.valueIrg.GetBytes(b, 0, 8);
lb = b[0] & 0xffL;
lb |= (b[1] & 0xffL) << 8;
lb |= (b[2] & 0xffL) << 16;
lb |= (b[3] & 0xffL) << 24;
lb |= (b[4] & 0xffL) << 32;
lb |= (b[5] & 0xffL) << 40;
lb |= (b[6] & 0xffL) << 48;
lb |= (b[7] & 0x7fL) << 56;
if (lb < maxexc) {
return lb % maxExclusive;
}
}
}