static BigDecimal pow(double val, int power){
return pow(new BigDecimal(val), power);
}
public static BigDecimal pow(BigDecimal val, int power){
BigDecimal value = BigDecimal.valueOf(1);
for(int i = 1; i <= power; i ++){
value = value.multiply(val);
}
return value;
}
public static BigDecimal factorial(int n){
BigDecimal value = BigDecimal.valueOf(1);
for(int i = 1; i <=n ; i++){
value = value.multiply(BigDecimal.valueOf(i));
}
return value;
}
public static void main(String args) {
if(args.length < 2){
System.out.println("usage: " + "java nz-baby.Pi " + " 参数(0-无穷大) 精度(1-4294967296)");
System.out.println("usage: " + "java nz-baby.Pi " + " n(0- ) scale(1-4294967296)");
System.exit(-1);
}
int n = Integer.parseInt(args[0]);
int scale = Integer.parseInt(args);
System.out.println("palgorithm n=" + n + " scale=" + scale);
System.out.println("start:" + new Date(System.currentTimeMillis()));
Pi p = new Pi();
p.run(n, scale);
System.out.println("end:" + new Date(System.currentTimeMillis()));
System.out.println("result=" + p.getResult());
}
}