Here you can find the source of getDigitNumber(double p)
public static int getDigitNumber(double p)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; import java.text.NumberFormat; public class Main { public static int getDigitNumber(double p) { NumberFormat formatter = new DecimalFormat(); formatter = new DecimalFormat("0.######E0"); String s = formatter.format(p); // String s = p + ""; // return s.length(); String ss = s.substring(s.indexOf("E") + 1); return Integer.parseInt(ss); }// w w w . jav a 2s.co m }