本文整理汇总了C#中UInt64类的典型用法代码示例。如果您正苦于以下问题:C# UInt64类的具体用法?C# UInt64怎么用?C# UInt64使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UInt64类属于命名空间,在下文中一共展示了UInt64类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: generate
public static int[] generate(UInt64 n, UInt64 start)
{
int[] ReturnArray = new int[n];
IntPtr d = primesieve_generate_n_primes(n, start, 2);
Marshal.Copy(d, ReturnArray, (int)0, (int)n);
return ReturnArray;
}
示例2: BigEndian
/// <summary>
/// Converts a <see cref="UInt64"/> to big endian notation.
/// </summary>
/// <param name="input">The <see cref="UInt64"/> to convert.</param>
/// <returns>The converted <see cref="UInt64"/>.</returns>
public static UInt64 BigEndian(UInt64 input)
{
if (!BitConverter.IsLittleEndian)
return input;
return Swap(input);
}
示例3: NewTotalCount
/// <summary>
/// A helper method for creating an object that represents a total count
/// of objects that the cmdlet would return without paging
/// (this can be more than the size of the page specified in the <see cref="First"/> cmdlet parameter).
/// </summary>
/// <param name="totalCount">a total count of objects that the cmdlet would return without paging</param>
/// <param name="accuracy">
/// accuracy of the <paramref name="totalCount"/> parameter.
/// <c>1.0</c> means 100% accurate;
/// <c>0.0</c> means that total count is unknown;
/// anything in-between means that total count is estimated
/// </param>
/// <returns>An object that represents a total count of objects that the cmdlet would return without paging</returns>
public PSObject NewTotalCount(UInt64 totalCount, double accuracy)
{
PSObject result = new PSObject(totalCount);
string toStringMethodBody = string.Format(
CultureInfo.CurrentCulture,
@"
$totalCount = $this.PSObject.BaseObject
switch ($this.Accuracy) {{
{{ $_ -ge 1.0 }} {{ '{0}' -f $totalCount }}
{{ $_ -le 0.0 }} {{ '{1}' -f $totalCount }}
default {{ '{2}' -f $totalCount }}
}}
",
CodeGeneration.EscapeSingleQuotedStringContent(CommandBaseStrings.PagingSupportAccurateTotalCountTemplate),
CodeGeneration.EscapeSingleQuotedStringContent(CommandBaseStrings.PagingSupportUnknownTotalCountTemplate),
CodeGeneration.EscapeSingleQuotedStringContent(CommandBaseStrings.PagingSupportEstimatedTotalCountTemplate));
PSScriptMethod toStringMethod = new PSScriptMethod("ToString", ScriptBlock.Create(toStringMethodBody));
result.Members.Add(toStringMethod);
accuracy = Math.Max(0.0, Math.Min(1.0, accuracy));
PSNoteProperty statusProperty = new PSNoteProperty("Accuracy", accuracy);
result.Members.Add(statusProperty);
return result;
}
示例4: Write
public override void Write(UInt64 val)
{
val = Utilities.SwapBytes(val);
base.Write(val);
if (AutoFlush) Flush();
}
示例5: UInt64
public static byte[] UInt64(UInt64 i, Endianness e = Endianness.Machine)
{
byte[] bytes = BitConverter.GetBytes(i);
if (NeedsFlipping(e)) Array.Reverse(bytes);
return bytes;
}
示例6: SwapBytes
public static UInt64 SwapBytes(UInt64 x)
{
// swap adjacent 32-bit blocks
x = (x >> 32) | (x << 32);
// swap adjacent 16-bit blocks
x = ((x & 0xFFFF0000FFFF0000) >> 16) | ((x & 0x0000FFFF0000FFFF) << 16);
// swap adjacent 8-bit blocks
return ((x & 0xFF00FF00FF00FF00) >> 8) | ((x & 0x00FF00FF00FF00FF) << 8);
}
示例7: User
public User(string login, UInt64 passwordHash, Int32 ID)
{
pLogin = login;
pPassword = new Password(passwordHash);
pID = ID;
pStaticAddressess = new List<UnifiedAddress>();
pDynamicAddressess = new List<UnifiedAddress>();
pCurrentAddress = null;
}
示例8: GetHammingDistance
public int GetHammingDistance(UInt64 firstValue, UInt64 secondValue)
{
UInt64 hammingBits = firstValue ^ secondValue;
int hammingValue = 0;
for (int i = 0; i < HashSize; i++) {
if (IsBitSet(hammingBits, i)) {
hammingValue += 1;
}
}
return hammingValue;
}
示例9: GetByteArray
/// <summary>
/// 将指定的无符号整数转换为字节数组
/// </summary>
/// <param name="value">无符号整数</param>
/// <param name="length">需要的元素个数</param>
/// <param name="maxLength">该无符号整数最多能转换的元素个数</param>
/// <returns></returns>
private static byte[] GetByteArray(UInt64 value, byte length, byte maxLength)
{
if (length < 1 || length > maxLength)
{
length = maxLength;
}
byte[] byteArray = new byte[length];
for (int i = 0; i < length; i++)
{
byteArray[i] = (byte)(value >> ((length - 1 - i) * 8));
}
return byteArray;
}
示例10: GetOutputStreamAt
public IOutputStream GetOutputStreamAt(UInt64 position)
{
ThrowCloningNotSuported("GetOutputStreamAt");
return null;
}
示例11: Seek
public void Seek(UInt64 position)
{
if (position > Int64.MaxValue)
{
ArgumentException ex = new ArgumentException(SR.IO_CannotSeekBeyondInt64MaxValue);
ex.SetErrorCode(HResults.E_INVALIDARG);
throw ex;
}
// Commented due to a reported CCRewrite bug. Should uncomment when fixed:
//Contract.EndContractBlock();
Stream str = EnsureNotDisposed();
Int64 pos = unchecked((Int64)position);
Debug.Assert(str != null);
Debug.Assert(str.CanSeek, "The underlying str is expected to support Seek, but it does not.");
Debug.Assert(0 <= pos && pos <= Int64.MaxValue, "Unexpected pos=" + pos + ".");
str.Seek(pos, SeekOrigin.Begin);
}
示例12: HexNumberToUInt64
private unsafe static Boolean HexNumberToUInt64(ref NumberBuffer number, ref UInt64 value)
{
Int32 i = number.scale;
if (i > UINT64_PRECISION || i < number.precision)
{
return false;
}
Char* p = number.digits;
Debug.Assert(p != null, "");
UInt64 n = 0;
while (--i >= 0)
{
if (n > (0xFFFFFFFFFFFFFFFF / 16))
{
return false;
}
n *= 16;
if (*p != '\0')
{
UInt64 newN = n;
if (*p != '\0')
{
if (*p >= '0' && *p <= '9')
{
newN += (UInt64)(*p - '0');
}
else
{
if (*p >= 'A' && *p <= 'F')
{
newN += (UInt64)((*p - 'A') + 10);
}
else
{
Debug.Assert(*p >= 'a' && *p <= 'f', "");
newN += (UInt64)((*p - 'a') + 10);
}
}
p++;
}
// Detect an overflow here...
if (newN < n)
{
return false;
}
n = newN;
}
}
value = n;
return true;
}
示例13: TryParseUInt64
internal unsafe static Boolean TryParseUInt64(String s, NumberStyles style, IFormatProvider provider, out UInt64 result)
{
NumberFormatInfo info = provider == null ? NumberFormatInfo.CurrentInfo : NumberFormatInfo.GetInstance(provider);
NumberBuffer number = new NumberBuffer();
result = 0;
if (!TryStringToNumber(s, style, ref number, info, false))
{
return false;
}
if ((style & NumberStyles.AllowHexSpecifier) != 0)
{
if (!HexNumberToUInt64(ref number, ref result))
{
return false;
}
}
else
{
if (!NumberToUInt64(ref number, ref result))
{
return false;
}
}
return true;
}
示例14: NumberToUInt64
private unsafe static Boolean NumberToUInt64(ref NumberBuffer number, ref UInt64 value)
{
Int32 i = number.scale;
if (i > UINT64_PRECISION || i < number.precision || number.sign)
{
return false;
}
char* p = number.digits;
Debug.Assert(p != null, "");
UInt64 n = 0;
while (--i >= 0)
{
if (n > (0xFFFFFFFFFFFFFFFF / 10))
{
return false;
}
n *= 10;
if (*p != '\0')
{
UInt64 newN = n + (UInt64)(*p++ - '0');
// Detect an overflow here...
if (newN < n)
{
return false;
}
n = newN;
}
}
value = n;
return true;
}
示例15: VerifyUInt64ExplicitCastFromBigInteger
private static void VerifyUInt64ExplicitCastFromBigInteger(UInt64 value)
{
BigInteger bigInteger = new BigInteger(value);
VerifyUInt64ExplicitCastFromBigInteger(value, bigInteger);
}