static int decimalPlaces(final double x){
  double y=x * 10.0;
  int dp=1;
  while (true) {
    if (dp == 10) {
      return 10;
    }
    final double z=MathUtils.round(y);
    final double del=Math.abs(z - y);
    if (del < 0.0000001) {
      return dp;
    }
    dp++;
    y=y * 10.0;
  }
}

static int decimalPlaces ( final double x ) { double y = x * 10.0 ; int dp = 1 ; while ( true ) { if ( dp == 10 ) { return 10 ; } final double z = MathUtils . round ( y ) ; final double del = Math . abs ( z - y ) ; if ( del < 0.0000001 ) { return dp ; } dp ++ ; y = y * 10.0 ; } }
compute the number of decimal places needed to reasonably display a double . done explicitly so that we can sharpen .
