INNER CODE UNIT · C#
Sample
sdrapkin/SecurityDriven.Inferno · CryptoRandom.cs:52
protected override double Sample() => NextDouble();
#region NextLong()
/// <summary>
/// Returns a nonnegative random number.
/// </summary>
/// <returns>
/// A 64-bit signed integer greater than or equal to zero and less than <see cref="F:System.Int64.MaxValue"/>.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public long NextLong()
{
long result;
do
{
result = GetRandomLong() & 0x7FFF_FFFF_FFFF_FFFF; // Mask away the sign bit so that we always return nonnegative integers
} while (result == long.MaxValue); // the range must be [0, long.MaxValue)