You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The pow function in UD60x18 reverts when x is lower than 1e18, because the log2 function is used in an intermediary step, and so in-flight negative values are required.
However, it is possible to circumvent this limitation by using this mathematical trick suggested by @FoxDev12 in #176 (which is closed now, unfortunately):
x^y = 1/((1/x)^y)
In practice, the idea is to refactor the pow function to look something like this:
if (xUint > uUNIT) {
result =exp2(mul(log2(x), y));
} elseif (xUint == uUNIT) {
result = UNIT;
} else {
UD60x18 rX =div(UNIT, x);
UD60x18 rResult =exp2(mul(log2(rX), y));
result =div(UNIT, rResult);
}
The text was updated successfully, but these errors were encountered:
The
pow
function inUD60x18
reverts whenx
is lower than 1e18, because thelog2
function is used in an intermediary step, and so in-flight negative values are required.However, it is possible to circumvent this limitation by using this mathematical trick suggested by @FoxDev12 in #176 (which is closed now, unfortunately):
In practice, the idea is to refactor the
pow
function to look something like this:The text was updated successfully, but these errors were encountered: