public class DataTypeTest {
public static void main(String[] args) {
double d = 12.0101;
int count = getRadixPoint(d);
System.out.println("位数: " + count);
}
private static int getRadixPoint(double d) {
String str = String.valueOf(d);
int index = str.indexOf(".");
str = str.substring(index + 1);
return str.length();
}
}
|