-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be computationally expensive with large values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not thrilled about the very generic name of this, but it makes sense to be compatible with ansible.
Adds a
root
and alog
filter 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