本文整理汇总了C#中UInt128.GetBitLength方法的典型用法代码示例。如果您正苦于以下问题:C# UInt128.GetBitLength方法的具体用法?C# UInt128.GetBitLength怎么用?C# UInt128.GetBitLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UInt128
的用法示例。
在下文中一共展示了UInt128.GetBitLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TauSumInnerWorkerLarge
private int TauSumInnerWorkerLarge(UInt128 y, ulong imin, ulong imax)
{
#if false
var sum = (uint)0;
for (var i = imin; i < imax; i++)
sum ^= (uint)(y / i);
return (int)(sum & 1);
#endif
#if false
var yRep = (MutableInteger)y;
var xRep = yRep.Copy();
var iRep = (MutableInteger)imin;
var store = new MutableIntegerStore(4);
var sum = (uint)0;
for (var i = imin; i < imax; i++)
{
sum ^= xRep.Set(yRep).Divide(iRep, store).LeastSignificantWord;
iRep.Increment();
}
return (int)(sum & 1);
#endif
#if false
// The quantity floor(y/d) is odd iff y mod 2d >= d.
var sum = (ulong)0;
for (var i = imin; i < imax; i++)
sum ^= y % (i << 1) - i;
sum >>= 63;
if (((imax - imin) & 1) != 0)
sum ^= 1;
return (int)(sum & 1);
#endif
#if false
if (y.IsPowerOfTwo)
{
var uBits = y.GetBitLength() - 32;
var sum = (uint)0;
var y0 = (UInt128)y.LeastSignificantWord;
var y12 = (ulong)(y >> 32);
for (var i = imin; i < imax; i++)
{
var y12mod = y12 % i;
var yPrime = y0 + ((y12 % i) << 32);
var shift = 64 - i.GetBitCount();
sum ^= (uint)(y / i);
}
return (int)(sum & 1);
}
#endif
#if false
var sum = (uint)0;
var i = imax - 1;
var current = (ulong)(y / (i + 1));
var delta = (ulong)(y / i - current);
var mod = (long)(y - (UInt128)current * (i + 1));
var imid = Math.Max(imin, (ulong)(y >> (64 - safetyBits)));
while (i >= imid)
{
mod += (long)(current - delta * i);
current += delta;
if (mod >= (long)i)
{
++delta;
++current;
mod -= (long)i;
if (mod >= (long)i)
break;
}
else if (mod < 0)
{
--delta;
--current;
mod += (long)i;
}
Debug.Assert(y / i == current);
sum ^= (uint)current;
--i;
}
while (i >= imin)
{
sum ^= (uint)(y / i);
--i;
}
return (int)(sum & 1);
#endif
#if true
var sum = (uint)0;
var i = imax - 1;
var current = (ulong)(y / (i + 1));
var delta = (ulong)(y / i) - current;
var mod = (long)(y - (UInt128)current * (i + 1));
var imid = Math.Max(imin, (ulong)(y >> (64 - safetyBits)));
var deltai = delta * (i + 1);
while (i >= imid)
{
deltai -= delta;
mod += (long)(current - deltai);
if (mod >= (long)i)
{
++delta;
deltai += i;
//.........这里部分代码省略.........