Here you can find the source of log10AbsCeil(BigDecimal x)
public static int log10AbsCeil(BigDecimal x)
//package com.java2s; //License from project: Open Source License import java.math.BigDecimal; import java.math.BigInteger; public class Main { public static int log10AbsCeil(BigInteger x) { if (x.signum() == 0) { throw new IllegalArgumentException("x == 0"); }//from w w w . ja va2 s . co m if (x.signum() < 0) { x = x.negate(); } if (x.equals(BigInteger.ONE)) { return 0; } return x.subtract(BigInteger.ONE).toString().length(); } public static int log10AbsCeil(BigDecimal x) { int log10 = log10AbsCeil(x.unscaledValue()); return subInts(log10, x.scale()); } public static int subInts(int a, int b) { if ((b > 0 && a < Integer.MIN_VALUE + b) || (b < 0 && a > Integer.MAX_VALUE + b)) { throw new ArithmeticException("int \"-\" overflow"); } return a - b; } }