Example usage for java.math BigInteger toString

List of usage examples for java.math BigInteger toString

Introduction

In this page you can find the example usage for java.math BigInteger toString.

Prototype

public String toString() 

Source Link

Document

Returns the decimal String representation of this BigInteger.

Usage

From source file:com.vangent.hieos.services.xds.bridge.utils.UUIDUtils.java

/**
 * Method description//from  ww  w .j  a  v  a 2  s  .co m
 *
 *
 * @param uuid
 * @param prefix
 *
 * @return
 */
public static String toOID(UUID uuid, String prefix) {

    String result = null;

    if ((uuid != null) && StringUtils.isNotBlank(prefix)) {

        String uuidstr = uuid.toString().replaceAll("-", "");
        BigInteger bi = new BigInteger(uuidstr, 16);

        result = String.format("%s.%s", prefix, bi.toString());
    }

    return result;
}

From source file:com.web.vehiclerouting.optaplanner.common.persistence.AbstractSolutionImporter.java

public static String getFlooredPossibleSolutionSize(BigInteger possibleSolutionSize) {
    if (possibleSolutionSize.compareTo(BigInteger.valueOf(1000L)) < 0) {
        return possibleSolutionSize.toString();
    }/*from  w  w w .j  av a  2s.  c  o m*/
    // TODO this is slow for machinereassingment's biggest dataset
    return "10^" + (possibleSolutionSize.toString().length() - 1);
}

From source file:org.optaplanner.examples.common.persistence.AbstractSolutionImporter.java

public static String getFlooredPossibleSolutionSize(BigInteger possibleSolutionSize) {
    if (possibleSolutionSize.compareTo(BigInteger.valueOf(1000L)) < 0) {
        return possibleSolutionSize.toString();
    }/*  www  .jav a 2 s. c om*/
    return "10^" + (BigIntegerMath.log10(possibleSolutionSize, RoundingMode.FLOOR));
}

From source file:org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil.java

public static NodeId nodeIdFromDatapathId(final BigInteger datapathId) {
    // FIXME: Convert to textual representation of datapathID
    String current = datapathId.toString();
    return new NodeId(OF_URI_PREFIX + current);
}

From source file:com.clustercontrol.repository.util.RepositoryUtil.java

/**
 * byte?BigInteger?????//from w  w w .  j  av a  2 s . c  om
 * @param ary ??
 * @returnBigInteger
 */
public static BigInteger byteToBigIntV6(byte[] ary) {

    BigInteger ret = new BigInteger(ary);
    log.debug("ary=" + ret.toString());

    return ret;
}

From source file:burstcoin.observer.service.ATService.java

public static String toUnsignedLong(long objectId) {
    if (objectId >= 0) {
        return String.valueOf(objectId);
    }//ww w  .ja va2 s .  co  m
    BigInteger id = BigInteger.valueOf(objectId).add(two64);
    return id.toString();
}

From source file:edu.macalester.tagrelatedness.KendallsCorrelation.java

private static BigDecimal getInitialApproximation(BigDecimal n) {
    BigInteger integerPart = n.toBigInteger();
    int length = integerPart.toString().length();
    if ((length % 2) == 0) {
        length--;/*  ww w. j av a 2s  .c  o  m*/
    }
    length /= 2;
    BigDecimal guess = ONE.movePointRight(length);
    return guess;
}

From source file:com.amazonaws.services.kinesis.clientlibrary.proxies.util.KinesisLocalFileDataCreator.java

/** Helper method to create a list of shards (which can then be used to generate data files).
 * @param numShards Number of shards//from   w w w.  ja va  2s. co m
 * @param shardIdPrefix Prefix for the shardIds
 * @param startingSequenceNumber Starting sequence number for all the shards
 * @return List of shards (with no reshard events).
 */
public static List<Shard> createShardList(int numShards, String shardIdPrefix,
        BigInteger startingSequenceNumber) {
    List<Shard> shards = new ArrayList<Shard>(numShards);

    SequenceNumberRange sequenceNumberRange = new SequenceNumberRange();
    sequenceNumberRange.setStartingSequenceNumber(startingSequenceNumber.toString());
    sequenceNumberRange.setEndingSequenceNumber(null);
    BigInteger perShardHashKeyRange = KinesisLocalFileProxy.MAX_HASHKEY_VALUE
            .divide(new BigInteger(Integer.toString(numShards)));
    BigInteger hashKeyRangeStart = new BigInteger("0");
    for (int i = 0; i < numShards; i++) {
        Shard shard = new Shard();
        shard.setShardId(shardIdPrefix + i);
        shard.setSequenceNumberRange(sequenceNumberRange);
        BigInteger hashKeyRangeEnd = hashKeyRangeStart.add(perShardHashKeyRange);
        HashKeyRange hashKeyRange = new HashKeyRange();
        hashKeyRange.setStartingHashKey(hashKeyRangeStart.toString());
        hashKeyRange.setEndingHashKey(hashKeyRangeEnd.toString());
        shards.add(shard);
    }

    return shards;
}

From source file:utils.Hash.java

/**
 * Creates a psedorandom string//from ww  w  .  j a  v a 2s.c om
 * @return Random String
 */
public static String randomString() {
    String result = new String();
    try {
        byte byteArray[] = new byte[16];
        SecureRandom psn1 = SecureRandom.getInstance("SHA1PRNG");
        psn1.setSeed(psn1.nextLong());
        psn1.nextBytes(byteArray);
        BigInteger bigInt = new BigInteger(byteArray);
        result = bigInt.toString();
        log.debug("Generated String = " + result);

    } catch (Exception e) {
        log.error("Random Number Error : " + e.toString());
    }
    return result;
}

From source file:utils.Hash.java

/**
 * Generates a small psedorandom string/*  w w  w. j ava2s.  com*/
 * @return Random String
 */
public static String smallRandomString() {
    String result = new String();
    try {
        byte byteArray[] = new byte[4];
        SecureRandom psn1 = SecureRandom.getInstance("SHA1PRNG");
        psn1.setSeed(psn1.nextLong());
        psn1.nextBytes(byteArray);
        BigInteger bigInt = new BigInteger(byteArray);
        result = bigInt.toString();
        log.debug("Generated String = " + result);

    } catch (Exception e) {
        log.error("Random Number Error : " + e.toString());
    }
    return result;
}