I want to implement 4.pow(0.5) #50
-
Can you help me, I want to implement 4.pow(0.5) |
Beta Was this translation helpful? Give feedback.
Answered by
PaulRBerg
Sep 22, 2021
Replies: 1 comment 7 replies
-
Hey @lailaibtc! You can do that calculation like this: // SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.4;
import "prb-math/contracts/PRBMathUD60x18.sol";
contract UnsignedConsumer {
using PRBMathUD60x18 for uint256;
function foo() external returns (uint256 result) {
const base = 4e18;
const exp = 5e17;
result = base.pow(exp);
}
} You can try this on Remix. The result you get be should be Make sure to read the NatSpec documentation for the |
Beta Was this translation helpful? Give feedback.
7 replies
Answer selected by
GalaxySciTech
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @lailaibtc! You can do that calculation like this:
You can try this on Remix. The result you get be should be
2000000000000000000
, which is2e18
.Make sure to read the NatSpec documentation for the
pow
function so that you understand how it works more precisely. Also check out this convertor tool that will help you convert between 18-decimals number (wads) and n…