Java Utililty Methods BigInteger Create

List of utility methods to do BigInteger Create

  1. HOME
  2. Java
  3. B
  4. BigInteger Create

Description

The list of methods to do BigInteger Create are organized into topic(s).

Method

BitSet Create(BigInteger value)
Create a bitset from a positive BigInteger.
if (value.compareTo(BigInteger.ZERO) < 0)
 throw new IllegalArgumentException("value must be greater than zero (" + value + ")");
int numbits = value.bitLength() + 1;
BitSet newBS = new BitSet(numbits);
for (int index = 0; index < numbits; index += 1) {
 if (value.testBit(index)) {
 newBS.set(index);
return newBS;
BigInteger createBigInteger(final String str)
create Big Integer
if (str == null) {
 return null;
int pos = 0; 
int radix = 10;
boolean negate = false; 
if (str.startsWith("-")) {
 negate = true;
...
BigInteger createBigInteger(final String str)

Convert a String to a BigInteger; since 3.2 it handles hex (0x or #) and octal (0) notations.

Returns null if the string is null.

if (str == null) {
 return null;
int pos = 0; 
int radix = 10;
boolean negate = false; 
if (str.startsWith("-")) {
 negate = true;
...
BigInteger createBigInteger(final String value)
This method creates a new big-integer.
return new BigInteger(value);
BigInteger createBigInteger(String str)
create Big Integer
if (str == null) {
 return null;
return new BigInteger(str);
BigInteger createBigInteger(String str)

Convert a String to a BigInteger.

Returns null if the string is null.

if (str == null) {
 return null;
return new BigInteger(str);
BigInteger hexToBigInteger(String hex)
hex To Big Integer
return new BigInteger(hex, 16);
BigInteger hexToBigInteger(String hex)
Convert hex to BigInteger.
if (hex == null) {
 return null;
if (hex.startsWith("0x")) {
 hex = hex.substring(2);
while (hex.length() > 1 && hex.charAt(0) == '0') {
 hex = hex.substring(1);
...
BigInteger toBigInteger(byte[] bytes)
to Big Integer
if (bytes[0] == -128) {
 return new BigInteger(bytes);
} else {
 return new BigInteger(1, bytes);
BigInteger toBigInteger(final byte[] array, final int offset, final int length)
to Big Integer
BigInteger result = new BigInteger(1, new byte[] {});
for (int i = (offset + length - 1); i >= offset; i--) {
 result = result.shiftLeft(8);
 result = result.or(BigInteger.valueOf(array[i] & 0xFF));
return result;


AltStyle によって変換されたページ (->オリジナル) /