Here you can find the source of getLength(BigDecimal v)
private static int getLength(BigDecimal v)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; public class Main { private static int getLength(BigDecimal v) { int signum = v.signum(); if (signum == 0) { // Special case for zero return 1; }/* ww w. j av a 2 s . com*/ return (signum < 0 ? 2 : 1) + (v.precision() + 1 + (v.scale() % 2 == 0 ? 0 : 1)) / 2; } }