# ERC20, how to calculate how many tokens for crowdsale?

If you look at this article, the total tokens for crowdsale is 100 tokens and defined in the code as

``````uint256 public maxTokens = 100000000000000000000;
``````

how come 100000000000000000000 becomes 100 tokens?

ERC20 tokens have a value called `decimals` which says what power of 10 you should multiply/divide things by. The ERC20 token you're looking at, like most tokens, uses `decimals = 18`, so everything is multiplied by 10^18 (a 1 with 18 zeros after it). So to represent 100 tokens, you use the value 100 * 10^18 == 10^20 == a 1 with 20 zeros after it, which is the number you see.
It's the responsibility of UI—e.g. tools like Etherscan, MetaMask, and MyEtherWallet—to take `decimals` into account and multiply and divide values as needed. So if your balance of an ERC20 token with 18 decimal places is 1000000000000000000, Etherscan will tell you you have 1 token. And if you ask MyEtherWallet to transfer 0.5 tokens, it will transfer the amount 500000000000000000.
• Does `decimals = 18` mean the token value can be allowed up to 18 decimal places? Ex: 0.218392749283928378 – bbusdriver Jun 16 '19 at 19:33
• From your answer, `10 * 10^18` isn't it supposed to be `100 * 10^18`? – bbusdriver Jun 16 '19 at 20:06