Add root and log filters.#299
Conversation
Codecov Report
@@ Coverage Diff @@
## master #299 +/- ##
===========================================
- Coverage 71.98% 71.78% -0.2%
- Complexity 1526 1558 +32
===========================================
Files 237 239 +2
Lines 4769 4881 +112
Branches 757 789 +32
===========================================
+ Hits 3433 3504 +71
- Misses 1071 1093 +22
- Partials 265 284 +19
Continue to review full report at Codecov.
|
| import ch.obermuhlner.math.big.BigDecimalMath; | ||
|
|
||
| @JinjavaDoc( | ||
| value = "Return the log of the input.", |
There was a problem hiding this comment.
"return the natural log value of the input"
|
|
||
| @Test | ||
| public void itCalculatesNthRootOfBigDecimal() { | ||
| BigDecimal result = ((BigDecimal) filter.filter(new BigDecimal(9765625d), interpreter, "5.0")); |
There was a problem hiding this comment.
can this be computationally expensive with large values?
There was a problem hiding this comment.
Performance is largely a function of precision in this case set to 50 digits. With such a low precision operations are in the nanoseconds range. The goal of this library we are using is for performance remain stable as the input grows so we should be safe http://obermuhlner.ch/wordpress/2016/06/02/bigdecimalmath/
|
|
||
| @Override | ||
| public String getName() { | ||
| return "log"; |
There was a problem hiding this comment.
I'm not thrilled about the very generic name of this, but it makes sense to be compatible with ansible.
Adds a
rootand alogfilter as requested here #292 similar to https://ansible-docs.readthedocs.io/zh/stable-2.0/rst/playbooks_filters.html#math.Complications: supporting BigDecimal and exact values requires adding a dependency on https://github.com/eobermuhlner/big-math