0

I am reading about ethereum (from technology stand point). I want to create an ICO smart contract (a typical ERC20 test token) where say if someone sends 0.1 ether to the contract address then they receive 10000 test tokens. However, can the receiving value (ie. 10000) be in fractions/floats like 1000.4500000000. I have read that EVM does not support floats. Is there a work around. Please assist

0

Generally, you just used fixed point arithmetic. In short, if you want to be able to send numbers with two decimal places, just multiply all the token values by 100 (and divide all the prices by 100). This is the purpose of the decimals variable in the token contracts here: https://ethereum.org/token.

For ether itself, numbers are always expressed in wei. 0.1 ether, for example, is 100000000000000000 wei.

Not the answer you're looking for? Browse other questions tagged or ask your own question.