I'm stuck with a very weird behaviour of my smart contract.
uint weiDue = calculateTotalWei(winningBets[i].tokensDeposited, winningBets[i].amounts, multipliers) / totalWeiBetWinningTeam * totalWeiBetLosingTeam; //debugging weiDueEv(calculateTotalWei(winningBets[i].tokensDeposited, winningBets[i].amounts, multipliers), totalWeiBetWinningTeam, totalWeiBetLosingTeam, weiDue);
The function calculateTotalWei returns uint and both totalWeiBetWinningTeam and totalWeiBetLosingTeam are also uints.
After debugging with event it seems like
weiDue = 100 / 200 * 1700 // gives 0, should be 850
on the other hand
weiDue = 100 / 100 * 1700 // gives 1700
What is this magic behaviour and how do I fix this? It seems like 100/200 is coerced to 0 before multipling by 1700 but why?