示例#1
0
 public T Next <T>(T max)
     where T : struct
 {
     if (typeof(T) == typeof(sbyte))
     {
         return(generic <T>(Int8Source.Next(int8(max))));
     }
     else if (typeof(T) == typeof(byte))
     {
         return(generic <T>(UInt8Source.Next(uint8(max))));
     }
     else if (typeof(T) == typeof(ushort))
     {
         return(generic <T>(Int16Source.Next(int16(max))));
     }
     else if (typeof(T) == typeof(ushort))
     {
         return(generic <T>(UInt16Source.Next(uint16(max))));
     }
     else if (typeof(T) == typeof(int))
     {
         return(generic <T>(Int32Source.Next(int32(max))));
     }
     else if (typeof(T) == typeof(uint))
     {
         return(generic <T>(UInt32Source.Next(uint32(max))));
     }
     else if (typeof(T) == typeof(long))
     {
         return(generic <T>(Int64Source.Next(int64(max))));
     }
     else if (typeof(T) == typeof(ulong))
     {
         return(generic <T>(UInt64Source.Next(uint64(max))));
     }
     else if (typeof(T) == typeof(float))
     {
         return(generic <T>(Float32Source.Next(float32(max))));
     }
     else if (typeof(T) == typeof(double))
     {
         return(generic <T>(Float64Source.Next(float64(max))));
     }
     else
     {
         throw unsupported <T>();
     }
 }
示例#2
0
        double IBoundPointSource <double> .Next(double max)
        {
            var whole = (double)Int64Source.Next((long)max);

            return(whole + NextF64());
        }