# Attempting to calculate a majority vote

I am trying to create a small voting system in a smart contract where a vote is passed when the majority of admins have voted. I now realise that this is not as easy as I thought, as there are no floats in Solidity, so I cannot simply do `(voteCount/adminCount)*100 > 50`. I noticed the problem when I tried to do `(2/3)*100` and it results in `0`.

How is something like this usually solved? Didn't pay much attention in math classes back in school, so the Google searches I've done on the topic didn't help me much.

• You can multiply both side by `adminCount`.
– Ismael
Sep 26, 2021 at 15:41
• what is `voteCount` (the count of all votes) ? I don't understand why voteCount could be lower than adminCount Sep 26, 2021 at 16:10
• Sep 26, 2021 at 18:25

Do first the multiplications and then divide: ` (voteCount*100/adminCount) > 50`

In the case of 2 votes and 3 admins you will get `200/3 = 66 > 50`

If you need more resolution (decimals) you can add a multiplier to both side of the inequality, for instance:

`decimals: 2;`

`(voteCount*100*(10**decimals)/adminCount) > 50*(10**decimals)`

Again in the case of 2 out of 3 votes you will get `20000/3 = 6666 > 5000`

Hope this helps