本文整理匯總了C#中BigInteger.multiply方法的典型用法代碼示例。如果您正苦於以下問題:C# BigInteger.multiply方法的具體用法?C# BigInteger.multiply怎麽用?C# BigInteger.multiply使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類BigInteger
的用法示例。
在下文中一共展示了BigInteger.multiply方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: multiplyByTenPow
/**
* Multiplies a number by a power of ten.
* This method is used in {@code BigDecimal} class.
* @param val the number to be multiplied
* @param exp a positive {@code long} exponent
* @return {@code val * 10<sup>exp</sup>}
*/
internal static BigInteger multiplyByTenPow(BigInteger val, long exp)
{
// PRE: exp >= 0
return ((exp < tenPows.Length)
? multiplyByPositiveInt(val, tenPows[(int)exp])
: val.multiply(powerOf10(exp)));
}
示例2: modPow2Inverse
/**
* @param x an odd positive number.
* @param n the exponent by which 2 is raised.
* @return {@code x<sup>-1</sup> (mod 2<sup>n</sup>)}.
*/
internal static BigInteger modPow2Inverse(BigInteger x, int n)
{
// PRE: (x > 0), (x is odd), and (n > 0)
BigInteger y = new BigInteger(1, new int[1 << n]);
y.numberLength = 1;
y.digits[0] = 1;
y.sign = 1;
for (int i = 1; i < n; i++) {
if (BitLevel.testBit(x.multiply(y), i)) {
// Adding 2^i to y (setting the i-th bit)
y.digits[i >> 5] |= (1 << (i & 31));
}
}
return y;
}
示例3: multiplyByFivePow
/**
* Multiplies a number by a power of five.
* This method is used in {@code BigDecimal} class.
* @param val the number to be multiplied
* @param exp a positive {@code int} exponent
* @return {@code val * 5<sup>exp</sup>}
*/
internal static BigInteger multiplyByFivePow(BigInteger val, int exp)
{
// PRE: exp >= 0
if (exp < fivePows.Length) {
return multiplyByPositiveInt(val, fivePows[exp]);
} else if (exp < bigFivePows.Length) {
return val.multiply(bigFivePows[exp]);
} else {// Large powers of five
return val.multiply(bigFivePows[1].pow(exp));
}
}