当前位置: 首页>>代码示例>>Java>>正文


Java BigInteger.toString方法代码示例

本文整理汇总了Java中java.math.BigInteger.toString方法的典型用法代码示例。如果您正苦于以下问题:Java BigInteger.toString方法的具体用法?Java BigInteger.toString怎么用?Java BigInteger.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.math.BigInteger的用法示例。


在下文中一共展示了BigInteger.toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toUnsignedLong

import java.math.BigInteger; //导入方法依赖的package包/类
public static String toUnsignedLong(long objectId) {
    if (objectId >= 0) {
        return String.valueOf(objectId);
    }
    BigInteger id = BigInteger.valueOf(objectId).add(two64);
    return id.toString();
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:8,代码来源:Convert.java

示例2: decodeBase900toBase10

import java.math.BigInteger; //导入方法依赖的package包/类
private static String decodeBase900toBase10(int[] codewords, int count) throws FormatException {
    BigInteger result = BigInteger.ZERO;
    for (int i = 0; i < count; i++) {
        result = result.add(EXP900[(count - i) - 1].multiply(BigInteger.valueOf((long) codewords[i])));
    }
    String resultString = result.toString();
    if (resultString.charAt(0) == '1') {
        return resultString.substring(1);
    }
    throw FormatException.getFormatInstance();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:12,代码来源:DecodedBitStreamParser.java

示例3: toHexString

import java.math.BigInteger; //导入方法依赖的package包/类
/**
 * return a hexadecimal printed representation of the specified
 * BigInteger object. the value is formatted to fit on lines of
 * at least 75 characters, with embedded newlines. Words are
 * separated for readability, with eight words (32 bytes) per line.
 */
public static String toHexString(BigInteger b) {
    String hexValue = b.toString(16);
    StringBuilder sb = new StringBuilder(hexValue.length()*2);

    if (hexValue.startsWith("-")) {
        sb.append("   -");
        hexValue = hexValue.substring(1);
    } else {
        sb.append("    ");     // four spaces
    }
    if ((hexValue.length()%2) != 0) {
        // add back the leading 0
        hexValue = "0" + hexValue;
    }
    int i=0;
    while (i < hexValue.length()) {
        // one byte at a time
        sb.append(hexValue.substring(i, i + 2));
        i+=2;
        if (i!= hexValue.length()) {
            if ((i%64) == 0) {
                sb.append("\n    ");     // line after eight words
            } else if (i%8 == 0) {
                sb.append(" ");     // space between words
            }
        }
    }
    return sb.toString();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:Debug.java

示例4: sha3String

import java.math.BigInteger; //导入方法依赖的package包/类
private static String sha3String(byte[] message, SHA3Digest digest, boolean bouncyencoder) {
    byte[] hash = doSha3(message, digest, bouncyencoder);
    if (bouncyencoder) {
        return Hex.toHexString(hash);
    } else {
        BigInteger bigInt = new BigInteger(1, hash);
        return bigInt.toString(16);
    }
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:10,代码来源:SHA3Helper.java

示例5: bigIntegerToBytes

import java.math.BigInteger; //导入方法依赖的package包/类
protected byte[]
bigIntegerToBytes(
	BigInteger	bi,
	int			num_bytes )
{
	String	str = bi.toString(16);

	while( str.length() < num_bytes*2 ){
		str = "0" + str;
	}

	return( ByteFormatter.decodeString(str));
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:14,代码来源:ProtocolDecoderPHE.java

示例6: toHex

import java.math.BigInteger; //导入方法依赖的package包/类
/**
 * Converts a byte array into a hexadecimal string.
 *
 * @param array the byte array to convert
 * @return a length*2 character string encoding the byte array
 */
private String toHex(byte[] array) {
  BigInteger bi = new BigInteger(1, array);
  String hex = bi.toString(16);
  int paddingLength = (array.length * 2) - hex.length();
  if (paddingLength > 0) {
    return String.format("%0" + paddingLength + "d", 0) + hex;
  } else {
    return hex;
  }
}
 
开发者ID:springuni,项目名称:springuni-particles,代码行数:17,代码来源:Pbkdf2PasswordSecurityImpl.java

示例7: getSpeed

import java.math.BigInteger; //导入方法依赖的package包/类
private static PortSpeedValue getSpeed(BigInteger speed, boolean portSpeedType) {
    String value = speed.toString();
    return value.equals("4000000")
            ? CollectUtil.createPortSpeed(4 * 1000 * 1000, "4M", portSpeedType)
            : value.equals("10000000")
            ? CollectUtil.createPortSpeed(10 * 1000 * 1000, "10M", portSpeedType)
            : value.equals("16000000")
            ? CollectUtil.createPortSpeed(16 * 1000 * 1000, "16M", portSpeedType)
            : value.equals("45000000")
            ? CollectUtil.createPortSpeed(45 * 1000 * 1000, "45M", portSpeedType)
            : value.equals("64000000")
            ? CollectUtil.createPortSpeed(64 * 1000 * 1000, "64M", portSpeedType)
            : value.equals("100000000")
            ? CollectUtil.createPortSpeed(100 * 1000 * 1000, "100M", portSpeedType)
            : value.equals("155000000")
            ? CollectUtil.createPortSpeed(155 * 1000 * 1000, "155M", portSpeedType)
            : value.equals("400000000")
            ? CollectUtil.createPortSpeed(400 * 1000 * 1000, "400M", portSpeedType)
            : value.equals("622000000")
            ? CollectUtil.createPortSpeed(622 * 1000 * 1000, "622M", portSpeedType)
            : value.equals("1000000000")
            ? CollectUtil.createPortSpeed(1000 * 1000 * 1000, "1000M", portSpeedType)
            : value.equals("4294967295")
            ? CollectUtil.createPortSpeed(10L * 1000L * 1000L * 1000L, "10G", portSpeedType)
            : value.equals("1544000")
            ? CollectUtil.createPortSpeed((long) (1.544 * 1000 * 1000), "1.544M", portSpeedType)
            : value.equals("2000000")
            ? CollectUtil.createPortSpeed(2 * 1000 * 1000, "2M", portSpeedType)
            : value.equals("2048000")
            ? CollectUtil.createPortSpeed((long) (2.048 * 1000 * 1000), "2.048M", portSpeedType)
            : value.equals("64000")
            ? CollectUtil.createPortSpeed(64 * 1000, "64k", portSpeedType)
            : CollectUtil.createPortSpeed(speed.longValue(), value, portSpeedType);
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:35,代码来源:CollectUtil.java

示例8: toHexString

import java.math.BigInteger; //导入方法依赖的package包/类
/**
 * return a hexadecimal printed representation of the specified
 * BigInteger object. the value is formatted to fit on lines of
 * at least 75 characters, with embedded newlines. Words are
 * separated for readability, with eight words (32 bytes) per line.
 */
public static String toHexString(BigInteger b) {
    String hexValue = b.toString(16);
    StringBuffer buf = new StringBuffer(hexValue.length()*2);

    if (hexValue.startsWith("-")) {
        buf.append("   -");
        hexValue = hexValue.substring(1);
    } else {
        buf.append("    ");     // four spaces
    }
    if ((hexValue.length()%2) != 0) {
        // add back the leading 0
        hexValue = "0" + hexValue;
    }
    int i=0;
    while (i < hexValue.length()) {
        // one byte at a time
        buf.append(hexValue.substring(i, i+2));
        i+=2;
        if (i!= hexValue.length()) {
            if ((i%64) == 0) {
                buf.append("\n    ");     // line after eight words
            } else if (i%8 == 0) {
                buf.append(" ");     // space between words
            }
        }
    }
    return buf.toString();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:36,代码来源:Debug.java

示例9: md5sum

import java.math.BigInteger; //导入方法依赖的package包/类
/**
 * Return the MD5 checksum of the given byte array
 * @param input
 * @return
 */
public static String md5sum(byte bytes[]) {
    MessageDigest digest = null;
    try {
        digest = MessageDigest.getInstance("MD5");
    } catch (NoSuchAlgorithmException ex) {
        throw new RuntimeException("Unable to compute md5sum for string", ex);
    }
    assert (digest != null);
    digest.update(bytes);
    BigInteger hash = new BigInteger(1, digest.digest());
    return (hash.toString(16));
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:18,代码来源:StringUtil.java

示例10: rsaEncrypt

import java.math.BigInteger; //导入方法依赖的package包/类
private static String rsaEncrypt(String text, String pubKey, String modulus) {
    text = new StringBuilder(text).reverse().toString();
    BigInteger rs = new BigInteger(String.format("%x", new BigInteger(1, text.getBytes())), 16)
            .modPow(new BigInteger(pubKey, 16), new BigInteger(modulus, 16));
    String r = rs.toString(16);
    int length = 256;
    if (r.length() >= length) {
        return r.substring(r.length() - 256, r.length());
    } else {
        while (r.length() < length) {
            r = 0 + r;
        }
        return r;
    }
}
 
开发者ID:wxz1211,项目名称:dooo,代码行数:16,代码来源:EncryptUtils.java

示例11: checkBigIntegerInIntRangeAndPositive

import java.math.BigInteger; //导入方法依赖的package包/类
private static int checkBigIntegerInIntRangeAndPositive(BigInteger b)
{
    if ((b.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) > 0) ||
        (b.compareTo(ZERO) <= 0))
    {
        throw new IllegalArgumentException("BigInteger not in Range: " + b.toString());
    }
    return b.intValue();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:10,代码来源:ParSet.java

示例12: DoubleColumn

import java.math.BigInteger; //导入方法依赖的package包/类
public DoubleColumn(final BigInteger data) {
	this(null == data ? (String) null : data.toString());
}
 
开发者ID:yaogdu,项目名称:datax,代码行数:4,代码来源:DoubleColumn.java

示例13: isHarshad

import java.math.BigInteger; //导入方法依赖的package包/类
/**
 * Tests if a {@link BigInteger} is a Harshad number.
 *
 * @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 {@code true} if {@code n} is a Harshad number, {@code false} if not,
 *         {@code null} if aborted.
 * */
public static Boolean isHarshad(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");

    final String nToString = n.toString();
    BigInteger sumOfDigits = ZERO;

    for (int j = 0; j < nToString.length(); j++) {
        sumOfDigits = sumOfDigits.add(new BigInteger(nToString.substring(j, j + 1)));

        if (abort != null && abort.get())
            return null;

    }

    return n.divideAndRemainder(sumOfDigits)[1].compareTo(ZERO) == 0;
}
 
开发者ID:MaXcRIMe,项目名称:Positive-Integers-Porperties,代码行数:33,代码来源:MathFunctions.java

示例14: toString

import java.math.BigInteger; //导入方法依赖的package包/类
public String toString()
{
    if (scale == 0)
    {
        return bigInt.toString();
    }

    BigInteger floorBigInt = floor();

    BigInteger fract = bigInt.subtract(floorBigInt.shiftLeft(scale));
    if (bigInt.signum() == -1)
    {
        fract = ECConstants.ONE.shiftLeft(scale).subtract(fract);
    }

    if ((floorBigInt.signum() == -1) && (!(fract.equals(ECConstants.ZERO))))
    {
        floorBigInt = floorBigInt.add(ECConstants.ONE);
    }
    String leftOfPoint = floorBigInt.toString();

    char[] fractCharArr = new char[scale];
    String fractStr = fract.toString(2);
    int fractLen = fractStr.length();
    int zeroes = scale - fractLen;
    for (int i = 0; i < zeroes; i++)
    {
        fractCharArr[i] = '0';
    }
    for (int j = 0; j < fractLen; j++)
    {
        fractCharArr[zeroes + j] = fractStr.charAt(j);
    }
    String rightOfPoint = new String(fractCharArr);

    StringBuilder sb = new StringBuilder(leftOfPoint);
    sb.append(".");
    sb.append(rightOfPoint);

    return sb.toString();
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:42,代码来源:SimpleBigDecimal.java

示例15: toString

import java.math.BigInteger; //导入方法依赖的package包/类
@Override
public String toString(BigInteger arg) {
    return arg.toString();
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:5,代码来源:BigIntAlgebra.java


注:本文中的java.math.BigInteger.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。