public static long Next(this IRandomGenerator <ulong> randomGenerator, long lessThan) { if (lessThan <= 0L) { return(0); } ulong num1 = BitTwiddling.PowerOf2Mask((ulong)lessThan); long num2; do { num2 = (long)randomGenerator.Next() & (long)num1; }while (num2 >= lessThan); return(num2); }
public static int Next(this IRandomGenerator <uint> randomGenerator, int lessThan) { if (lessThan <= 0) { return(0); } uint num1 = BitTwiddling.PowerOf2Mask((uint)lessThan); int num2; do { num2 = (int)randomGenerator.Next() & (int)num1; }while (num2 >= lessThan); return(num2); }
public static ulong NextPowerOf2(ulong v) { v = BitTwiddling.PowerOf2Mask(v); ++v; return(v); }
public static uint NextPowerOf2(uint v) { v = BitTwiddling.PowerOf2Mask(v); ++v; return(v); }