Determine Number of Decimal Place using BigDecimal
<p>I was interested to have the following getNumberOfDecimalPlace function :</p>

<pre><code>    System.out.println("0 = " + Utils.getNumberOfDecimalPlace(0));          // 0
    System.out.println("1.0 = " + Utils.getNumberOfDecimalPlace(1.0));      // 0
    System.out.println("1.01 = " + Utils.getNumberOfDecimalPlace(1.01));    // 2
    System.out.println("1.012 = " + Utils.getNumberOfDecimalPlace(1.012));  // 3
    System.out.println("0.01 = " + Utils.getNumberOfDecimalPlace(0.01));    // 2
    System.out.println("0.012 = " + Utils.getNumberOfDecimalPlace(0.012));  // 3
</code></pre>

<p>May I know how can I implement getNumberOfDecimalPlace, by using BigDecimal?</p>

<p>The following code doesn't work as expected :</p>

<pre><code>public static int getNumberOfDecimalPlace(double value) {
    final BigDecimal bigDecimal = new BigDecimal("" + value);
    final String s = bigDecimal.toPlainString();
    System.out.println(s);
    final int index = s.indexOf('.');
    if (index &lt; 0) {
        return 0;
    }
    return s.length() - 1 - index;
}
</code></pre>

<p>The following get printed :</p>

<pre><code>0.0
0 = 1
1.0
1.0 = 1
1.01
1.01 = 2
1.012
1.012 = 3
0.01
0.01 = 2
0.012
0.012 = 3
</code></pre>

<p>However, for case 0, 1.0, it doesn't work well. I expect, "0" as result. But they turned out to be "0.0" and "1.0". This will return "1" as result.</p>
