Can any explain what this section of code does: _num = (_num & ~(1L << 63));
I've have been reading up on RNGCryptoServiceProvider and came across http://codethinktank.blogspot.co.uk/2013/04/cryptographically-secure-pseudo-random.html with the code, I can follow most the code except for the section above.
I understand it ensuring that all numbers are positive, but I do not know how its doing that.
Full code
public static long GetInt64(bool allowNegativeValue = false)
{
using (RNGCryptoServiceProvider _rng = new RNGCryptoServiceProvider())
{
byte[] _obj = new byte[8];
_rng.GetBytes(_obj);
long _num = BitConverter.ToInt64(_obj, 0);
if (!allowNegativeValue)
{
_num = (_num & ~(1L << 63));
}
return _num;
}
}
Any help explaining it would be appreciated