Пример #1
0
		//min and max is inclusive
		long getrand (System.Random r, long min, long max)
		{
			byte[] b = new byte[8];
			r.NextBytes (b);
			ulong tmp = System.BitConverter.ToUInt64 (b, 0);
			//Response.Output.WriteLine (tmp);
			//Response.Output.WriteLine (decimal.Round (((((decimal)tmp) * (decimal)(max - min) / (decimal)ulong.MaxValue))));
			return (long)decimal.Round (((((decimal)tmp) * (decimal)(max - min) / (decimal)ulong.MaxValue))) + min;
		}
Пример #2
0
 internal void GenerateNewNumber(System.Random randomGenerator)
 {
     byte[] buffer = new byte[1];
     randomGenerator.NextBytes(buffer);
     licenseRandomNumber = buffer[0];
 }
Пример #3
0
 internal static long RandomToLong(System.Random r)
 {
     byte[] buffer = new byte[8];
     r.NextBytes(buffer);
     return (((long) BitConverter.ToUInt64(buffer, 0)) & 0x7fffffffffffffffL);
 }
Пример #4
0
 internal static long RandomToLong(System.Random r)
 {
   byte[] buffer = new byte[8];
   r.NextBytes(buffer);
   return (long) BitConverter.ToUInt64(buffer, 0) & long.MaxValue;
 }