Author: fanningpj
Date: Sat Apr 30 08:31:31 2022
New Revision: 1900418

URL: http://svn.apache.org/viewvc?rev=1900418&view=rev
Log:
support sqrtpi function

Modified:
    poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/Sqrtpi.java
    
poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestSqrtpi.java

Modified: 
poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/Sqrtpi.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/Sqrtpi.java?rev=1900418&r1=1900417&r2=1900418&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/Sqrtpi.java 
(original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/Sqrtpi.java 
Sat Apr 30 08:31:31 2022
@@ -56,6 +56,8 @@ public class Sqrtpi implements FreeRefFu
                 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();

Modified: 
poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestSqrtpi.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestSqrtpi.java?rev=1900418&r1=1900417&r2=1900418&view=diff
==============================================================================
--- 
poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestSqrtpi.java 
(original)
+++ 
poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestSqrtpi.java 
Sat Apr 30 08:31:31 2022
@@ -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);
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to