本文整理汇总了Java中java.math.BigInteger.intValue方法的典型用法代码示例。如果您正苦于以下问题:Java BigInteger.intValue方法的具体用法?Java BigInteger.intValue怎么用?Java BigInteger.intValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.math.BigInteger
的用法示例。
在下文中一共展示了BigInteger.intValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isTriangular
import java.math.BigInteger; //导入方法依赖的package包/类
/**
* Tests if a {@link BigInteger} is triangular.
*
* @param n The BigInteger to be tested.
* @param abort An {@link AtomicBoolean} used to abort the execution
* for whatever reason; Can be null.
* @throws NullPointerException if {@code n} is null.
* @throws IllegalArgumentException if {@code n} is less than or equal to zero.
* @return an {@link Integer} representing its position in the triangular sequence,
* {@code -1} if it's not a triangular number, {@code null} if aborted.
*/
public static Integer isTriangular(final BigInteger n, final AtomicBoolean abort) {
if (n == null)
throw new NullPointerException("n value can't be null");
if (n.compareTo(ZERO) <= 0)
throw new IllegalArgumentException("n value must be greater than zero");
if (n.compareTo(ONE) == 0)
return 1;
final BigInteger test = n.multiply(TWO);
final BigInteger testSqrt = bigIntegerNRoot(test, 2, abort);
if (testSqrt == null)
return null;
return test.compareTo(testSqrt.multiply(testSqrt.add(ONE))) == 0 ? testSqrt.intValue() : -1;
}
示例2: writeField
import java.math.BigInteger; //导入方法依赖的package包/类
private void writeField(
ByteArrayOutputStream out,
BigInteger fieldValue)
{
int byteCount = (fieldValue.bitLength() + 6) / 7;
if (byteCount == 0)
{
out.write(0);
}
else
{
BigInteger tmpValue = fieldValue;
byte[] tmp = new byte[byteCount];
for (int i = byteCount - 1; i >= 0; i--)
{
tmp[i] = (byte)((tmpValue.intValue() & 0x7f) | 0x80);
tmpValue = tmpValue.shiftRight(7);
}
tmp[byteCount - 1] &= 0x7f;
out.write(tmp, 0, tmp.length);
}
}
示例3: isTetrahedral
import java.math.BigInteger; //导入方法依赖的package包/类
/**
* Tests if a {@link BigInteger} is tetrahedral.
*
* @param n The BigInteger to be tested.
* @param abort An {@link AtomicBoolean} used to abort the execution
* for whatever reason; Can be null.
* @throws NullPointerException if {@code n} is null.
* @throws IllegalArgumentException if {@code n} is less than or equal to zero.
* @return an {@link Integer} representing its position in the tetrahedral sequence,
* {@code -1} if it's not a tetrahedral number, {@code null} if aborted.
* */
public static Integer isTetrahedral(final BigInteger n, final AtomicBoolean abort) {
if (n == null)
throw new NullPointerException("n value can't be null");
if (n.compareTo(ZERO) <= 0)
throw new IllegalArgumentException("n value must be greater than zero");
if (n.compareTo(ONE) == 0)
return 1;
final BigInteger test = n.multiply(SIX);
final BigInteger testCurt = bigIntegerNRoot(test, 3, abort);
if (testCurt == null)
return null;
return test.compareTo(testCurt.multiply(testCurt.add(ONE).multiply(testCurt.add(TWO)))) == 0 ?
testCurt.intValue() : -1;
}
示例4: McElieceCCA2PublicKey
import java.math.BigInteger; //导入方法依赖的package包/类
private McElieceCCA2PublicKey(ASN1Sequence seq)
{
oid = ((ASN1ObjectIdentifier)seq.getObjectAt(0));
BigInteger bigN = ((ASN1Integer)seq.getObjectAt(1)).getValue();
n = bigN.intValue();
BigInteger bigT = ((ASN1Integer)seq.getObjectAt(2)).getValue();
t = bigT.intValue();
matrixG = ((ASN1OctetString)seq.getObjectAt(3)).getOctets();
}
示例5: MethodData
import java.math.BigInteger; //导入方法依赖的package包/类
/**
* Constructs a MethodData object.
* @param encoding a Der-encoded data.
* @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
* @exception IOException if an I/O error occurs while reading encoded data.
*/
public MethodData(DerValue encoding) throws Asn1Exception, IOException {
DerValue der;
if (encoding.getTag() != DerValue.tag_Sequence) {
throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
der = encoding.getData().getDerValue();
if ((der.getTag() & 0x1F) == 0x00) {
BigInteger bint = der.getData().getBigInteger();
methodType = bint.intValue();
}
else
throw new Asn1Exception(Krb5.ASN1_BAD_ID);
if (encoding.getData().available() > 0) {
der = encoding.getData().getDerValue();
if ((der.getTag() & 0x1F) == 0x01) {
methodData = der.getData().getOctetString();
}
else throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
if (encoding.getData().available() > 0)
throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
示例6: Pfx
import java.math.BigInteger; //导入方法依赖的package包/类
public Pfx(
ASN1Sequence seq)
{
BigInteger version = ((DERInteger)seq.getObjectAt(0)).getValue();
if (version.intValue() != 3)
{
throw new IllegalArgumentException("wrong version for PFX PDU");
}
contentInfo = ContentInfo.getInstance(seq.getObjectAt(1));
if (seq.size() == 3)
{
macData = MacData.getInstance(seq.getObjectAt(2));
}
}
示例7: TODO
import java.math.BigInteger; //导入方法依赖的package包/类
@GwtIncompatible // BigIntegerMath // TODO(cpovirk): GWT-enable BigIntegerMath
public void testBinomial() {
for (int n = 0; n <= 50; n++) {
for (int k = 0; k <= n; k++) {
BigInteger expectedBig = BigIntegerMath.binomial(n, k);
int expectedInt = fitsInInt(expectedBig) ? expectedBig.intValue() : Integer.MAX_VALUE;
assertEquals(expectedInt, IntMath.binomial(n, k));
}
}
}
示例8: ECNamedCurveSpec
import java.math.BigInteger; //导入方法依赖的package包/类
public ECNamedCurveSpec(
String name,
ECCurve curve,
org.bouncycastle.math.ec.ECPoint g,
BigInteger n,
BigInteger h)
{
super(convertCurve(curve, null), convertPoint(g), n, h.intValue());
this.name = name;
}
示例9: getAllOrganizations
import java.math.BigInteger; //导入方法依赖的package包/类
@Override
@RolesAllowed("MARKETPLACE_OWNER")
public List<VOOrganization> getAllOrganizations(String marketplaceId)
throws ObjectNotFoundException {
List<VOOrganization> voOrganizations = new ArrayList<>();
List<Object[]> organizations = marketplaceServiceLocal
.getOrganizationsWithMarketplaceAccess(marketplaceId);
for (Object[] object : organizations) {
VOOrganization voOrganization = new VOOrganization();
BigInteger orgKey = (BigInteger) object[0];
voOrganization.setKey(orgKey.longValue());
voOrganization.setOrganizationId((String) object[1]);
voOrganization.setName((String) object[2]);
boolean hasAccess = (object[3] == null) ? false : true;
voOrganization.setHasGrantedAccessToMarketplace(hasAccess);
BigInteger noOfSubs = (BigInteger) object[4];
boolean hasSubscriptions = noOfSubs.intValue() > 0;
voOrganization.setHasSubscriptions(hasSubscriptions);
BigInteger noOfServices = (BigInteger) object[5];
boolean hasPublishedServices = noOfServices.intValue() > 0;
voOrganization.setHasPublishedServices(hasPublishedServices);
voOrganizations.add(voOrganization);
}
return voOrganizations;
}
示例10: sqrt
import java.math.BigInteger; //导入方法依赖的package包/类
/**
* Returns the square root of {@code x}, rounded with the specified rounding mode.
*
* @throws IllegalArgumentException if {@code x < 0}
* @throws ArithmeticException if {@code mode} is {@link RoundingMode#UNNECESSARY} and
* {@code sqrt(x)} is not an integer
*/
@GwtIncompatible // TODO
@SuppressWarnings("fallthrough")
public static BigInteger sqrt(BigInteger x, RoundingMode mode) {
checkNonNegative("x", x);
if (fitsInLong(x)) {
return BigInteger.valueOf(LongMath.sqrt(x.longValue(), mode));
}
BigInteger sqrtFloor = sqrtFloor(x);
switch (mode) {
case UNNECESSARY:
checkRoundingUnnecessary(sqrtFloor.pow(2).equals(x)); // fall through
case FLOOR:
case DOWN:
return sqrtFloor;
case CEILING:
case UP:
int sqrtFloorInt = sqrtFloor.intValue();
boolean sqrtFloorIsExact =
(sqrtFloorInt * sqrtFloorInt == x.intValue()) // fast check mod 2^32
&& sqrtFloor.pow(2).equals(x); // slow exact check
return sqrtFloorIsExact ? sqrtFloor : sqrtFloor.add(BigInteger.ONE);
case HALF_DOWN:
case HALF_UP:
case HALF_EVEN:
BigInteger halfSquare = sqrtFloor.pow(2).add(sqrtFloor);
/*
* We wish to test whether or not x <= (sqrtFloor + 0.5)^2 = halfSquare + 0.25. Since both x
* and halfSquare are integers, this is equivalent to testing whether or not x <=
* halfSquare.
*/
return (halfSquare.compareTo(x) >= 0) ? sqrtFloor : sqrtFloor.add(BigInteger.ONE);
default:
throw new AssertionError();
}
}
示例11: transform
import java.math.BigInteger; //导入方法依赖的package包/类
public String transform(PropertyValue value, String result) {
double floatValue;
if (value.getType().toLowerCase().equals("s")
|| value.getType().toLowerCase().equals("string")) {
return result;
}
if (value.getLSB() != null) {
BigInteger val = parse(value, result);
if (!value.mask().equals(BigInteger.ZERO)) {
val = val.and(value.mask());
}
if (!value.shift().equals(0)) {
val = val.shiftRight(value.shift());
}
if (value.getSigned() && val.bitLength() == (value.size() * 4)) {
BigInteger complement =
new BigInteger(new String(new char[value.size()]).replace("\0", "F"), 16);
val = val.subtract(complement);
}
if (!objectCache.getTransformData()) {
int intValue = val.intValue();
return String.valueOf(intValue);
}
floatValue = val.doubleValue();
} else {
floatValue = Float.parseFloat(result);
}
if (!value.base().equals(0)) {
floatValue = Math.pow(value.base(), floatValue);
}
floatValue = floatValue * value.scale();
floatValue = floatValue + value.offset();
if (value.getType().toLowerCase().equals("f")
|| value.getType().toLowerCase().equals("float")) {
return String.valueOf(floatValue);
}
return String.valueOf(Math.round(floatValue));
}
示例12: toIntArray
import java.math.BigInteger; //导入方法依赖的package包/类
/**
* Private helper method for serialization. To be compatible with old
* versions of JDK.
* @return components in an int array, if all the components are less than
* Integer.MAX_VALUE. Otherwise, null.
*/
private int[] toIntArray() {
int length = encoding.length;
int[] result = new int[20];
int which = 0;
int fromPos = 0;
for (int i = 0; i < length; i++) {
if ((encoding[i] & 0x80) == 0) {
// one section [fromPos..i]
if (i - fromPos + 1 > 4) {
BigInteger big = new BigInteger(pack(encoding, fromPos, i-fromPos+1, 7, 8));
if (fromPos == 0) {
result[which++] = 2;
BigInteger second = big.subtract(BigInteger.valueOf(80));
if (second.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) == 1) {
return null;
} else {
result[which++] = second.intValue();
}
} else {
if (big.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) == 1) {
return null;
} else {
result[which++] = big.intValue();
}
}
} else {
int retval = 0;
for (int j = fromPos; j <= i; j++) {
retval <<= 7;
byte tmp = encoding[j];
retval |= (tmp & 0x07f);
}
if (fromPos == 0) {
if (retval < 80) {
result[which++] = retval / 40;
result[which++] = retval % 40;
} else {
result[which++] = 2;
result[which++] = retval - 80;
}
} else {
result[which++] = retval;
}
}
fromPos = i+1;
}
if (which >= result.length) {
result = Arrays.copyOf(result, which + 10);
}
}
return Arrays.copyOf(result, which);
}
示例13: transform
import java.math.BigInteger; //导入方法依赖的package包/类
public String transform(PropertyValue value, String result) {
double floatValue;
// Do not perform transforms on non-numeric fields
if (nonNumeric(value)) {
return result;
}
if (value.getLSB() != null) {
BigInteger val = parse(value, result);
if (!value.mask().equals(BigInteger.ZERO)) {
val = val.and(value.mask());
}
if (!value.shift().equals(0)) {
val = val.shiftRight(value.shift());
}
if (value.getSigned() && val.bitLength() == (value.size() * 4)) {
BigInteger complement =
new BigInteger(new String(new char[value.size()]).replace("\0", "F"), 16);
val = val.subtract(complement);
}
if (!objectCache.getTransformData()) {
int intValue = val.intValue();
return String.valueOf(intValue);
}
floatValue = val.doubleValue();
} else {
floatValue = Float.parseFloat(result);
}
if (!value.base().equals(0)) {
floatValue = Math.pow(value.base(), floatValue);
}
floatValue = floatValue * value.scale();
floatValue = floatValue + value.offset();
if (value.getType().toLowerCase().equals("f")
|| value.getType().toLowerCase().equals("float")) {
return String.valueOf(floatValue);
}
return String.valueOf(Math.round(floatValue));
}
示例14: checkSigned
import java.math.BigInteger; //导入方法依赖的package包/类
/**
* Throw exception if value out of range (long version)
*
* @param value Value to check
* @return value if it is in range
* @throws ArithmeticException if value is out of range
*/
public static short checkSigned(BigInteger value) throws ArithmeticException {
if (value.compareTo(BigInteger.ZERO) < 0 || value.intValue() > MAX_VALUE) {
throw new ArithmeticException("Value is out of range : " + value);
}
return value.shortValue();
}
示例15: checkSigned
import java.math.BigInteger; //导入方法依赖的package包/类
/**
* Throw exception if value out of range (long version)
*
* @param value Value to check
* @return value if it is in range
* @throws ArithmeticException if value is out of range
*/
public static byte checkSigned(BigInteger value) throws ArithmeticException {
if (value.compareTo(BigInteger.ZERO) < 0 || value.intValue() > MAX_VALUE) {
throw new ArithmeticException("Value is out of range : " + value);
}
return value.byteValue();
}