5

simple problem, but i can't seem to wrap my head around it in solidity.

how can i do 2^0.3 (exponent smaller then 1) in solidity using integers.

thanks in advance K.

2
  • 1
    Solidity can only do exponentiation of integers where the base of the exponent can be a signed or unsigned integer and the exponent is an unsigned integer. The EVM does not have direct support for fractions or fixed point numbers, so this isn't an issue with solidity.
    – hrkrshnn
    Sep 23, 2020 at 17:35
  • 1
    However, one way around the problem would be to use integers to model a floating point number, and use a Taylor series for a^b to compute the exponent. This seems to have an implementation of `e^x.
    – hrkrshnn
    Sep 23, 2020 at 17:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.