mirror of https://github.com/apache/poi.git
update _g_div_gp
This commit is contained in:
parent
9965dc74db
commit
8b859879e4
|
@ -74,11 +74,14 @@ public class Rate implements Function {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double _g_div_gp(double r, double n, double p, double x, double y, double w) {
|
private static double _g_div_gp(double r, double n, double p, double x, double y, double w) {
|
||||||
double t1 = Math.pow(r+1, n);
|
double t1 = Math.pow(r + 1.0, n);
|
||||||
double t2 = Math.pow(r+1, n-1);
|
double t2 = Math.pow(r + 1.0, n - 1.0);
|
||||||
return (y + t1*x + p*(t1 - 1)*(r*w + 1)/r) /
|
double g = y + t1 * x + p * (t1 - 1.0) * (r * w + 1.0) / r;
|
||||||
(n*t2*x - p*(t1 - 1)*(r*w + 1)/(Math.pow(r, 2) + n*p*t2*(r*w + 1)/r +
|
double gp = (n * t2 * x
|
||||||
p*(t1 - 1)*w/r));
|
- p * (t1 - 1.0) * (r * w + 1.0) / (Math.pow(r, 2.0))
|
||||||
|
+ n * p * t2 * (r * w + 1.0) / r
|
||||||
|
+ p * (t1 - 1.0) * w / r);
|
||||||
|
return g / gp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -169,4 +169,16 @@ final class TestRate {
|
||||||
assertDouble(fe, cell, "RATE(360.0,6.56,-2000.0)", 0.0009480170844060, 0.000001);
|
assertDouble(fe, cell, "RATE(360.0,6.56,-2000.0)", 0.0009480170844060, 0.000001);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testBugxxxxx() throws Exception {
|
||||||
|
try (HSSFWorkbook wb = new HSSFWorkbook()) {
|
||||||
|
HSSFSheet sheet = wb.createSheet();
|
||||||
|
HSSFRow row = sheet.createRow(0);
|
||||||
|
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
|
||||||
|
HSSFCell cell = row.createCell(0);
|
||||||
|
assertDouble(fe, cell, "RATE(22,30000,20000,-82257625,0,0.1)", 0.35397960290713076, 0.000001);
|
||||||
|
assertDouble(fe, cell, "RATE(22,10000,10000,-313562750,0,0.1)", 0.5252278265995758, 0.000001);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue