本文整理了Java中java.math.BigInteger.getLowestSetBit()
方法的一些代码示例,展示了BigInteger.getLowestSetBit()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BigInteger.getLowestSetBit()
方法的具体详情如下:
包路径:java.math.BigInteger
类名称:BigInteger
方法名:getLowestSetBit
[英]Returns the position of the lowest set bit in the two's complement representation of this BigInteger. If all bits are zero (this==0) then -1 is returned as result.
Implementation Note: Usage of this method is not recommended as the current implementation is not efficient.
[中]返回此BigInteger的两个补码表示形式中最低设置位的位置。如果所有位都为零(此==0),则返回-1作为结果。
实施说明:不建议使用此方法,因为当前的实施效率不高。
代码示例来源:origin: google/guava
/** Returns {@code true} if {@code x} represents a power of two. */
public static boolean isPowerOfTwo(BigInteger x) {
checkNotNull(x);
return x.signum() > 0 && x.getLowestSetBit() == x.bitLength() - 1;
}
代码示例来源:origin: google/j2objc
/** Returns {@code true} if {@code x} represents a power of two. */
public static boolean isPowerOfTwo(BigInteger x) {
checkNotNull(x);
return x.signum() > 0 && x.getLowestSetBit() == x.bitLength() - 1;
}
代码示例来源:origin: prestodb/presto
/** Returns {@code true} if {@code x} represents a power of two. */
public static boolean isPowerOfTwo(BigInteger x) {
checkNotNull(x);
return x.signum() > 0 && x.getLowestSetBit() == x.bitLength() - 1;
}
代码示例来源:origin: wildfly/wildfly
/** Returns {@code true} if {@code x} represents a power of two. */
public static boolean isPowerOfTwo(BigInteger x) {
checkNotNull(x);
return x.signum() > 0 && x.getLowestSetBit() == x.bitLength() - 1;
}
代码示例来源:origin: google/guava
(twiceSignifFloor & 1) != 0 && ((signifFloor & 1) != 0 || absX.getLowestSetBit() < shift);
long signifRounded = increment ? signifFloor + 1 : signifFloor;
long bits = (long) (exponent + EXPONENT_BIAS) << SIGNIFICAND_BITS;
代码示例来源:origin: prestodb/presto
(twiceSignifFloor & 1) != 0 && ((signifFloor & 1) != 0 || absX.getLowestSetBit() < shift);
long signifRounded = increment ? signifFloor + 1 : signifFloor;
long bits = (long) ((exponent + EXPONENT_BIAS)) << SIGNIFICAND_BITS;
代码示例来源:origin: google/j2objc
(twiceSignifFloor & 1) != 0 && ((signifFloor & 1) != 0 || absX.getLowestSetBit() < shift);
long signifRounded = increment ? signifFloor + 1 : signifFloor;
long bits = (long) ((exponent + EXPONENT_BIAS)) << SIGNIFICAND_BITS;
代码示例来源:origin: wildfly/wildfly
(twiceSignifFloor & 1) != 0 && ((signifFloor & 1) != 0 || absX.getLowestSetBit() < shift);
long signifRounded = increment ? signifFloor + 1 : signifFloor;
long bits = (long) ((exponent + EXPONENT_BIAS)) << SIGNIFICAND_BITS;
代码示例来源:origin: robovm/robovm
exponent -= 2;
lowestSetBit = mantissa.getLowestSetBit();
discardedSize = mantissa.bitLength() - 54;
if (discardedSize > 0) {// (n > 54)
代码示例来源:origin: robovm/robovm
q = q.divide(gcd);
k = q.getLowestSetBit();
q = q.shiftRight(k);
代码示例来源:origin: robovm/robovm
ks[i] = rpTmp.getLowestSetBit();
rpTmp = rpTmp.clearBit(ks[i]);
代码示例来源: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: stackoverflow.com
int twos = denominator.getLowestSetBit();
代码示例来源:origin: org.freemarker/freemarker
&& (bitLength <= MAX_FLOAT_OR_INT_LOG_2
|| bitLength == MAX_FLOAT_OR_INT_LOG_2 + 1
&& biNum.getLowestSetBit() >= MAX_FLOAT_OR_INT_LOG_2)) {
return new BigIntegerOrFloat(biNum);
} else if ((typeFlags & TypeFlags.DOUBLE) != 0
&& (bitLength <= MAX_DOUBLE_OR_LONG_LOG_2
|| bitLength == MAX_DOUBLE_OR_LONG_LOG_2 + 1
&& biNum.getLowestSetBit() >= MAX_DOUBLE_OR_LONG_LOG_2)) {
return new BigIntegerOrDouble(biNum);
} else {
代码示例来源:origin: org.sonatype.sisu/sisu-guava
/**
* Returns {@code true} if {@code x} represents a power of two.
*/
public static boolean isPowerOfTwo(BigInteger x) {
checkNotNull(x);
return x.signum() > 0 && x.getLowestSetBit() == x.bitLength() - 1;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/**
* Returns {@code true} if {@code x} represents a power of two.
*/
public static boolean isPowerOfTwo(BigInteger x) {
checkNotNull(x);
return x.signum() > 0 && x.getLowestSetBit() == x.bitLength() - 1;
}
代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger
/** Returns {@code true} if {@code x} represents a power of two. */
public static boolean isPowerOfTwo(BigInteger x) {
checkNotNull(x);
return x.signum() > 0 && x.getLowestSetBit() == x.bitLength() - 1;
}
代码示例来源:origin: com.atlassian.guava/guava
/**
* Returns {@code true} if {@code x} represents a power of two.
*/
public static boolean isPowerOfTwo(BigInteger x) {
checkNotNull(x);
return x.signum() > 0 && x.getLowestSetBit() == x.bitLength() - 1;
}
代码示例来源:origin: com.alibaba.citrus.tool/antx-autoexpand
@Override
protected boolean isPowerOfTwo(Object value) {
BigInteger bintValue = (BigInteger) value;
int bitIndex = bintValue.getLowestSetBit();
if (bitIndex < 0) {
return false;
}
return bintValue.clearBit(bitIndex).equals(BigInteger.ZERO);
}
};
代码示例来源:origin: apache/jena
@Override
public NodeValue exec(NodeValue x)
{
if ( ! x.isInteger() )
throw new ExprEvalException("evenInteger: Not an intger: "+x) ;
int i = x.getInteger().getLowestSetBit() ;
boolean b = (i == -1) || ( i != 0 ) ;
return NodeValue.makeNodeBoolean( b ) ;
}
内容来源于网络,如有侵权,请联系作者删除!