diff --git a/docs/references/functions.md b/docs/references/functions.md index d79f8bc5..7db5ea52 100644 --- a/docs/references/functions.md +++ b/docs/references/functions.md @@ -27,7 +27,7 @@ Available through the _ExpressionConfiguration.StandardFunctionsDictionary_ cons | NOT(value) | Boolean negation, implemented as a function (for compatibility) | | RANDOM() | Produces a random value between 0 and 1 | | ROUND(value, scale) | Rounds the given value to the specified scale, using the current rounding mode | -| SQRT(value) | Square root function | +| SQRT(value) | Square root function. Uses the implementation from _The Java Programmers Guide To numerical Computing_ by Ronald Mak, 2002. | | SUM(value, ...) | Returns the sum of all parameters. If a parameter is of type _ARRAY_, the sum of all elements is calculated. | | SWITCH(expression, value1, result1, [value2-N, result2-N ...], [default]) | Returns the _result_ correponding to the first matching _value_ in the specified _expression_ or an optional _default_ value if no match found. | diff --git a/src/main/java/com/ezylang/evalex/functions/basic/SqrtFunction.java b/src/main/java/com/ezylang/evalex/functions/basic/SqrtFunction.java index ffe4ecc7..8662bb23 100644 --- a/src/main/java/com/ezylang/evalex/functions/basic/SqrtFunction.java +++ b/src/main/java/com/ezylang/evalex/functions/basic/SqrtFunction.java @@ -24,7 +24,10 @@ import java.math.BigInteger; import java.math.MathContext; -/** Square root function, uses the standard {@link BigDecimal#sqrt(MathContext)} implementation. */ +/** + * Square root function, uses the implementation from The Java Programmers Guide To numerical + * Computing by Ronald Mak, 2002. + */ @FunctionParameter(name = "value", nonNegative = true) public class SqrtFunction extends AbstractFunction { @@ -34,8 +37,9 @@ public EvaluationValue evaluate( /* * From The Java Programmers Guide To numerical Computing - * (Ronald Mak, 2003) + * (Ronald Mak, 2002) */ + BigDecimal x = parameterValues[0].getNumberValue(); MathContext mathContext = expression.getConfiguration().getMathContext();