MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / digits

Method digits

ij/src/main/java/ij/gui/GenericDialog.java:995–1013  ·  view source on GitHub ↗

Author: Michael Kaul

(double d)

Source from the content-addressed store, hash-verified

993
994 /** Author: Michael Kaul */
995 private static int digits(double d) {
996 if (d == (int)d)
997 return 0;
998 String s = Double.toString(d);
999 int ePos = s.indexOf("E");
1000 if (ePos==-1)
1001 ePos = s.indexOf("e");
1002 int dotPos = s.indexOf( "." );
1003 int digits = 0;
1004 if (ePos==-1 )
1005 digits = s.substring(dotPos+1).length();
1006 else {
1007 String number = s.substring( dotPos + 1, ePos );
1008 if (!number.equals( "0" ))
1009 digits += number.length( );
1010 digits = digits - Integer.valueOf(s.substring(ePos+1));
1011 }
1012 return digits;
1013 }
1014
1015 private void addSlider(String label, double minValue, double maxValue, double defaultValue, double scale, int digits) {
1016 @AstroImageJ(reason = "Value text box on Mac is two characters too narrow.", modified = true)

Callers 1

addSliderMethod · 0.95

Calls 6

substringMethod · 0.80
valueOfMethod · 0.80
lengthMethod · 0.65
toStringMethod · 0.45
indexOfMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected