本文整理匯總了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;
}
}