本文整理汇总了C#中BigInteger.BitLength方法的典型用法代码示例。如果您正苦于以下问题:C# BigInteger.BitLength方法的具体用法?C# BigInteger.BitLength怎么用?C# BigInteger.BitLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BigInteger
的用法示例。
在下文中一共展示了BigInteger.BitLength方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExpandedDouble
public ExpandedDouble(BigInteger frac, int binaryExp)
{
if (frac.BitLength() != 64)
{
throw new ArgumentException("bad bit length");
}
_significand = frac;
_binaryExponent = binaryExp;
}
示例2: Normalise64bit
public void Normalise64bit()
{
int oldBitLen = _significand.BitLength();
int sc = oldBitLen - C_64;
if (sc == 0)
{
return;
}
if (sc < 0)
{
throw new InvalidOperationException("Not enough precision");
}
_binaryExponent += sc;
if (sc > 32)
{
int highShift = (sc - 1) & 0xFFFFE0;
_significand = _significand>>(highShift);
sc -= highShift;
oldBitLen -= highShift;
}
if (sc < 1)
{
throw new InvalidOperationException();
}
_significand = Rounder.Round(_significand, sc);
if (_significand.BitLength() > oldBitLen)
{
sc++;
_binaryExponent++;
}
_significand = _significand>>(sc);
}
示例3: mulShift
private void mulShift(BigInteger multiplicand, int multiplierShift)
{
_significand = _significand*multiplicand;
_binaryExponent += multiplierShift;
// check for too much precision
int sc = (_significand.BitLength() - MIN_PRECISION) & unchecked((int)0xFFFFFFE0);
// mask Makes multiples of 32 which optimises BigInt32.ShiftRight
if (sc > 0)
{
// no need to round because we have at least 8 bits of extra precision
_significand = _significand>>(sc);
_binaryExponent += sc;
}
}