I would suggest you to calculate this in Wei, that will solve your problem.
Go to https://etherconverter.online/, enter 1 in the "Ether" field and set the price to that in wei. I have made a little example, use only if tested well and if you solved security issues!
contract Crowdsale {
uint tokenPrice = 500000000000000 wei;
uint public tokensToGet = 0;
function buyToken() payable returns (uint){
tokensToGet = msg.value / tokenPrice;
return tokensToGet;
}
}
Instead of "wei" you could also use "szabo" etc. like seen on the page. Please make sure to only use lowercase ("WEI", "Wei", "weI" would not work).
If you now would send 1 Ether, it would convert it with the price per token (0.0005) and tokensToGet would be 2000 (= 2.000 tokens). I habe made "tokensToGet" public because I use Remix and can then directly output this variable. Test it on Remix and use the Javascript VM :). Hope I helped!