inclusive() public method

public inclusive ( ) : bool
return bool
示例#1
0
        public static long random(Range r)
        {
            rand.GetBytes(randBytes);
            long v = BitConverter.ToInt64(randBytes, 0);

            if (r == null)
            {
                return(v);
            }
            if (v < 0)
            {
                v = -v;
            }
            long start = r.start();
            long end   = r.end();

            if (r.inclusive())
            {
                ++end;
            }
            if (end <= start)
            {
                throw ArgErr.make("Range end < start: " + r).val;
            }
            return(start + (v % (end - start)));
        }
示例#2
0
文件: FanInt.cs 项目: nomit007/f4
 public static long random(Range r)
 {
     rand.GetBytes(randBytes);
       long v = BitConverter.ToInt64(randBytes, 0);
       if (r == null) return v;
       if (v < 0) v = -v;
       long start = r.start();
       long end   = r.end();
       if (r.inclusive()) ++end;
       if (end <= start) throw ArgErr.make("Range end < start: " + r).val;
       return start + (v % (end-start));
 }