本文整理了Java中java.math.BigInteger.divideAndRemainder()
方法的一些代码示例,展示了BigInteger.divideAndRemainder()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BigInteger.divideAndRemainder()
方法的具体详情如下:
包路径:java.math.BigInteger
类名称:BigInteger
方法名:divideAndRemainder
[英]Returns a two element BigInteger array containing this / divisor at index 0 and this % divisor at index 1.
[中]返回一个两元素的BigInteger数组,该数组在索引0处包含此/除数,在索引1处包含此%除数。
代码示例来源:origin: apache/hive
/**
* Scale down a BigInteger by a power of 10 and round off if necessary using ROUND_HALF_UP.
* @return The scaled and rounded BigInteger.
*/
private static BigInteger doBigIntegerScaleDown(BigInteger unscaledValue, int scaleDown) {
BigInteger[] quotientAndRemainder = unscaledValue.divideAndRemainder(BigInteger.TEN.pow(scaleDown));
BigInteger quotient = quotientAndRemainder[0];
BigInteger round = quotientAndRemainder[1].divide(BigInteger.TEN.pow(scaleDown - 1));
if (round.compareTo(BIG_INTEGER_FIVE) >= 0) {
quotient = quotient.add(BigInteger.ONE);
}
return quotient;
}
代码示例来源:origin: debezium/debezium
private static LocalDateTime nanosToLocalDateTimeUTC(long epocNanos) {
// the pg plugin stores date/time info as microseconds since epoch
BigInteger epochMicrosBigInt = BigInteger.valueOf(epocNanos);
BigInteger[] secondsAndNanos = epochMicrosBigInt.divideAndRemainder(BigInteger.valueOf(TimeUnit.SECONDS.toNanos(1)));
return LocalDateTime.ofInstant(Instant.ofEpochSecond(secondsAndNanos[0].longValue(), secondsAndNanos[1].longValue()),
ZoneOffset.UTC);
}
代码示例来源:origin: alibaba/canal
BigInteger[] dandr = bi.divideAndRemainder(divideBy);
bi = dandr[0];
int digit = dandr[1].intValue();
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Return the spacing between lines of a paragraph. The units of the return value depends on the
* {@link LineSpacingRule}. If AUTO, the return value is in lines, otherwise the return
* value is in points
*
* @return a double specifying points or lines.
*/
public double getSpacingBetween() {
CTSpacing spacing = getCTSpacing(false);
if (spacing == null || !spacing.isSetLine()) {
return -1;
} else if (spacing.getLineRule() == null || spacing.getLineRule() == STLineSpacingRule.AUTO) {
BigInteger[] val = spacing.getLine().divideAndRemainder(BigInteger.valueOf(240L));
return val[0].doubleValue() + (val[1].doubleValue() / 240L);
}
BigInteger[] val = spacing.getLine().divideAndRemainder(BigInteger.valueOf(20L));
return val[0].doubleValue() + (val[1].doubleValue() / 20L);
}
代码示例来源:origin: robovm/robovm
private static BigDecimal divideBigIntegers(BigInteger scaledDividend, BigInteger scaledDivisor, int scale, RoundingMode roundingMode) {
BigInteger[] quotAndRem = scaledDividend.divideAndRemainder(scaledDivisor); // quotient and remainder
代码示例来源:origin: apache/hive
bigInteger.divideAndRemainder(BIG_INTEGER_LONGWORD_MULTIPLIER);
fastResult.fast0 = quotientAndRemainder[1].longValue();
BigInteger quotient = quotientAndRemainder[0];
quotient.divideAndRemainder(BIG_INTEGER_LONGWORD_MULTIPLIER);
fastResult.fast1 = quotientAndRemainder[1].longValue();
quotient = quotientAndRemainder[0];
代码示例来源:origin: org.freemarker/freemarker
BigInteger n1 = toBigInteger(first);
BigInteger n2 = toBigInteger(second);
BigInteger[] divmod = n1.divideAndRemainder(n2);
if (divmod[1].equals(BigInteger.ZERO)) {
return divmod[0];
代码示例来源:origin: kingthy/TVRemoteIME
for (int i = 0; i < KEY_LENGTH_WORDS; i++)
res = rr.divideAndRemainder(r32);
rr = res[0];
rem = res[1];
myRr[i] = rem.intValue();
res = n.divideAndRemainder(r32);
n = res[0];
rem = res[1];
代码示例来源:origin: apache/hive
BigInteger[] quotientAndRemainder = bigInteger.divideAndRemainder(BIG_INTEGER_TEN);
代码示例来源:origin: robovm/robovm
quotAndRem = mantissa.divideAndRemainder(powerOfTen);
代码示例来源:origin: robovm/robovm
quotAndRem = q.divideAndRemainder(FIVE_POW[i]);
if (quotAndRem[1].signum() == 0) {
l += i;
代码示例来源:origin: robovm/robovm
quotAndRem = strippedBI.divideAndRemainder(TEN_POW[i]);
代码示例来源:origin: konsoletyper/teavm
BigInteger mantissaDigitMask = pow10(BigInteger.ONE, mantissaLength - 1);
for (int i = mantissaLength - 1; i >= exponentPos; --i) {
BigInteger[] parts = mantissa.divideAndRemainder(mantissaDigitMask);
buffer.append(forDigit(Math.abs(parts[0].intValue())));
mantissa = parts[1];
int count = 0;
for (int i = visibleExponent - 1; i >= limit; --i) {
BigInteger[] parts = mantissa.divideAndRemainder(mantissaDigitMask);
buffer.append(forDigit(Math.abs(parts[0].intValue())));
mantissa = parts[1];
代码示例来源:origin: konsoletyper/teavm
BigInteger mantissaDigitMask = pow10(BigInteger.ONE, mantissaLength - 1);
for (int i = 0; i < significantIntDigits; ++i) {
BigInteger[] parts = mantissa.divideAndRemainder(mantissaDigitMask);
buffer.append(forDigit(Math.abs(parts[0].intValue())));
mantissa = parts[1];
BigInteger[] parts = mantissa.divideAndRemainder(mantissaDigitMask);
buffer.append(forDigit(Math.abs(parts[0].intValue())));
mantissa = parts[1];
代码示例来源:origin: robovm/robovm
BigInteger[] integerAndFraction = getUnscaledValue().divideAndRemainder(sizeOfFraction);
long newScale = (long)scale - discardedPrecision;
int compRem;
代码示例来源:origin: robovm/robovm
divideAndRemainder(divisor.getUnscaledValue());
quotAndRem = strippedBI.divideAndRemainder(TEN_POW[i]);
if ((quotAndRem[1].signum() == 0) &&
((resultPrecision - i >= mcPrecision)
代码示例来源:origin: robovm/robovm
/**
* Returns this {@code BigDecimal} as a big integer instance if it has no
* fractional part. If this {@code BigDecimal} has a fractional part, i.e.
* if rounding would be necessary, an {@code ArithmeticException} is thrown.
*
* @return this {@code BigDecimal} as a big integer value.
* @throws ArithmeticException
* if rounding is necessary.
*/
public BigInteger toBigIntegerExact() {
if ((scale == 0) || (isZero())) {
return getUnscaledValue();
} else if (scale < 0) {
return getUnscaledValue().multiply(Multiplication.powerOf10(-(long)scale));
} else {// (scale > 0)
BigInteger[] integerAndFraction;
// An optimization before do a heavy division
if ((scale > approxPrecision()) || (scale > getUnscaledValue().getLowestSetBit())) {
throw new ArithmeticException("Rounding necessary");
}
integerAndFraction = getUnscaledValue().divideAndRemainder(Multiplication.powerOf10(scale));
if (integerAndFraction[1].signum() != 0) {
// It exists a non-zero fractional part
throw new ArithmeticException("Rounding necessary");
}
return integerAndFraction[0];
}
}
代码示例来源:origin: robovm/robovm
newScale += trailingZeros;
quotAndRem = quotAndRem[0].divideAndRemainder( divisor.getUnscaledValue() );
integerQuot = quotAndRem[0];
quotAndRem = integerQuot.divideAndRemainder(TEN_POW[i]);
if ((quotAndRem[1].signum() == 0)
&& (newScale - i >= diffScale)) {
代码示例来源:origin: prestodb/presto
BigInteger rescaledDividend = dividendBigInteger.multiply(bigIntegerTenToNth(dividendRescaleFactor));
BigInteger rescaledDivisor = divisorBigInteger.multiply(bigIntegerTenToNth(divisorRescaleFactor));
BigInteger[] expectedQuotientAndRemainder = rescaledDividend.divideAndRemainder(rescaledDivisor);
BigInteger expectedQuotient = expectedQuotientAndRemainder[0];
BigInteger expectedRemainder = expectedQuotientAndRemainder[1];
代码示例来源:origin: robovm/robovm
quotAndRem = integralValue.divideAndRemainder(TEN_POW[i]);
if ((quotAndRem[1].signum() == 0)
&& (tempScale - i >= newScale)) {
内容来源于网络,如有侵权,请联系作者删除!