1

I can not get the answer of the expression

int256 test2 = ((0.0035+1)**120)*(10**18);

TypeError: Type rational_const 2021...(389 digits omitted)...2001 / 1329...(371 digits omitted)...0000 is not implicitly convertible to expected type int256. Try converting to type ufixed256x58 or use an explicit conversion.

int256 test2 = ((0.0035+1)**4)*(10**18);

This expression does not give an error

How can I solve such an expression with the help of Solidity?

int256 test2 = ((0.0035+1)**120)*(10**18);
  • The issue is caused because the result is not an integer (with 4 as exponent it is an integer). Either calculate the result externally to solidity and use the result directly or try to convince solidity developers to implement conversion from rationals to int256. – Ismael May 11 '18 at 4:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.