mirror of https://github.com/apache/poi.git
support sqrtpi function
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1900418 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9eb82c1185
commit
e4bd111489
|
@ -56,6 +56,8 @@ public class Sqrtpi implements FreeRefFunction {
|
|||
return ErrorEval.NUM_ERROR;
|
||||
}
|
||||
final double result = Math.sqrt(Math.PI * d);
|
||||
//NumberToTextConverter reduces the precision to what Excel uses internally
|
||||
//without this conversion, `result` is too precise
|
||||
return new NumberEval(Double.parseDouble(NumberToTextConverter.toText(result)));
|
||||
} catch (EvaluationException e) {
|
||||
return e.getErrorEval();
|
||||
|
|
|
@ -39,6 +39,7 @@ final class TestSqrtpi {
|
|||
//https://support.microsoft.com/en-us/office/sqrtpi-function-1fb4e63f-9b51-46d6-ad68-b3e7a8b519b4
|
||||
@Test
|
||||
void testBasic() {
|
||||
//the expected values were observed in my copy of Excel
|
||||
confirmValue(Arrays.asList(1), 1.77245385090552);
|
||||
confirmValue(Arrays.asList(2), 2.506628274631);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue