The pow
function in UD60x18
does not work with bases lower than 1
#172
-
Hi! I'm not very sure about the input lower & upper bounds, as well as precision in some scenarios such as x^y. My code is something like this:
From the name I assume that UD60x18 is with a 1e18 precision so an 1e18 input is actually 1.
I also tried some other cases such as: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @jinqiao0423, thank you opening this discussion. This is not a bug. It's a known limitation of the
The reason for this limitation is that the The solution is simple: just use
Actually, the revert happens only when the base is lower than 1 (see the implementation of |
Beta Was this translation helpful? Give feedback.
-
Update: since #182 has been merged, the Refer to the NatSpec comments for documentation: Lines 453 to 481 in 97170d0 |
Beta Was this translation helpful? Give feedback.
Update: since #182 has been merged, the
UD60x18.pow
function works with bases lower than 1e18 🎉Refer to the NatSpec comments for documentation:
prb-math/src/ud60x18/Math.sol
Lines 453 to 481 in 97170d0