import com.jb.tools.Calculate;
public class MathNum {
public MathNum() {
}
/**
* 取得小数点后两位,num为得到的字符串(即需要精确的数字)
* @param num String
* @return String
*/
public static String getNum(String num) {
String num_result = "0";
num_result = getNum(num, 2);
return num_result;
}
/**
* 根据取得的参数得到小数的精确值,num为得到的字符串(即需要精确的数字),precision为需要精确到小数点后的位数
* @param num String
* @param precision int
* @return String
*/
public static String getNum(String num, int precision) {
return Calculate.formatDoubleToRemainBit(new Double(num),precision);
}
public static void main(String[] args) {
System.out.println("MathNum.getNum(0.0256000,3)==="+MathNum.getNum("0.0256000",3));
}
}
public class MathNum {
public MathNum() {
}
/**
* 取得小数点后两位,num为得到的字符串(即需要精确的数字)
* @param num String
* @return String
*/
public static String getNum(String num) {
String num_result = "0";
num_result = getNum(num, 2);
return num_result;
}
/**
* 根据取得的参数得到小数的精确值,num为得到的字符串(即需要精确的数字),precision为需要精确到小数点后的位数
* @param num String
* @param precision int
* @return String
*/
public static String getNum(String num, int precision) {
return Calculate.formatDoubleToRemainBit(new Double(num),precision);
}
public static void main(String[] args) {
System.out.println("MathNum.getNum(0.0256000,3)==="+MathNum.getNum("0.0256000",3));
}
}