I have the following code snippet inside my contract:
plans[1100] = Plan(7, 3);
plans[1101] = Plan(7, 2.5);
plans[1102] = Plan(15, 4);
plans[1103] = Plan(30, 6);
plans[1104] = Plan(30, 5);
When I try to compile my contract, I encounter the following error:
CompileError: /home/nimashiri/react-dapp/contracts/TrustTrade.sol:172:31: TypeError: Invalid type for argument in function call. Invalid implicit conversion from rational_const 5 / 2 to uint256 requested.
plans[1101] = Plan(7, 2.5);
I was wondering if you help me with this case.
Thanks, Nima.
Plan
? Solidity doesn't have floating point support. It does work for intermediate results when the final is an integer. For exampleuint256 a = 2.5 * 1000
works but it fails foruint256 a = 5 / 3 * 1000
fails.Plan
. It is a struct: ` struct Plan {uint256 period; uint256 interest;}`