@Test public void testCountDecimalFractionDigits() { assertEquals(0, countDecimalFractionDigits(-65.0)); assertEquals(1, countDecimalFractionDigits(-65.5)); assertEquals(6, countDecimalFractionDigits( 65.123456)); assertEquals(0, countDecimalFractionDigits(1.23456E+200)); assertEquals(1, countDecimalFractionDigits(5E-1)); assertEquals(5, countDecimalFractionDigits(5E-5)); assertEquals(10, countDecimalFractionDigits(5E-10)); assertEquals(200, countDecimalFractionDigits(5E-200)); assertEquals(203, countDecimalFractionDigits(5.125E-200)); }
public static int countDecimalFractionDigits(final double value) { final String asText = Double.toString(value); final int exp = asText.indexOf('E'); int upper, power; if (exp >= 0) { upper = exp; power = Integer.parseInt(asText.substring(exp+1)); } else { upper = asText.length(); power = 0; } while ((asText.charAt(--upper)) == '0'); return Math.max(upper - asText.indexOf('.') - power, 0); }
XMath { public static int countDecimalFractionDigits(final double value) { final String asText = Double.toString(value); final int exp = asText.indexOf('E'); int upper, power; if (exp >= 0) { upper = exp; power = Integer.parseInt(asText.substring(exp+1)); } else { upper = asText.length(); power = 0; } while ((asText.charAt(--upper)) == '0'); return Math.max(upper - asText.indexOf('.') - power, 0); } }
XMath { public static int countDecimalFractionDigits(final double value) { final String asText = Double.toString(value); final int exp = asText.indexOf('E'); int upper, power; if (exp >= 0) { upper = exp; power = Integer.parseInt(asText.substring(exp+1)); } else { upper = asText.length(); power = 0; } while ((asText.charAt(--upper)) == '0'); return Math.max(upper - asText.indexOf('.') - power, 0); } private  XMath(); }
XMath { public static int countDecimalFractionDigits(final double value) { final String asText = Double.toString(value); final int exp = asText.indexOf('E'); int upper, power; if (exp >= 0) { upper = exp; power = Integer.parseInt(asText.substring(exp+1)); } else { upper = asText.length(); power = 0; } while ((asText.charAt(--upper)) == '0'); return Math.max(upper - asText.indexOf('.') - power, 0); } private  XMath(); static double pow10(final double x); static strictfp double pow10(final int x); static int sgn(final double x); static int sgn(final float x); static int sgn(long x); static int sgn(int x); static short sgn(short x); static byte sgn(byte x); static double roundIfAlmostInteger(final double value, int maxULP); static double trimDecimalFractionDigits(final double value, final int maxULP, int n); static int countDecimalFractionDigits(final double value); static float toNaN(int index); static synchronized int primeNumber(final int index); static int[] divisors(int number); }
XMath { public static int countDecimalFractionDigits(final double value) { final String asText = Double.toString(value); final int exp = asText.indexOf('E'); int upper, power; if (exp >= 0) { upper = exp; power = Integer.parseInt(asText.substring(exp+1)); } else { upper = asText.length(); power = 0; } while ((asText.charAt(--upper)) == '0'); return Math.max(upper - asText.indexOf('.') - power, 0); } private  XMath(); static double pow10(final double x); static strictfp double pow10(final int x); static int sgn(final double x); static int sgn(final float x); static int sgn(long x); static int sgn(int x); static short sgn(short x); static byte sgn(byte x); static double roundIfAlmostInteger(final double value, int maxULP); static double trimDecimalFractionDigits(final double value, final int maxULP, int n); static int countDecimalFractionDigits(final double value); static float toNaN(int index); static synchronized int primeNumber(final int index); static int[] divisors(int number);  }