Java examples for java.math:BigInteger
find BigInteger Nearest Power Of Ten
//package com.java2s; import java.math.BigInteger; public class Main { public static void main(String[] argv) throws Exception { BigInteger bint = new BigInteger("1234"); System.out.println(findNearestPowerOfTen(bint)); }/*from w ww . ja va2 s . co m*/ public static BigInteger findNearestPowerOfTen(BigInteger bint) { BigInteger divisor = BigInteger.ONE; int length = bint.toString().length(); for (int i = 0; i < length - 1; i++) { divisor = divisor.multiply(BigInteger.TEN); } return divisor; } }