I want to create a simple voting program with php, but I get a problem in rounding out the results of the voting.
I have some values from each of the existing topics, for example:
$TotalVote = 13;
$Value1 = 6;
$Value2 = 4;
$Value3 = 1;
$Value4 = 1;
$Value5 = 1;
Echo 'Value 1:'. $Result1 = round ($value1 / $totalVote * 100);
Echo '<br>';
Echo 'Value 2:'. $Result2 = round ($value2 / $totalVote * 100);
Echo '<br>';
Echo 'Value 3:'. $Result3 = round ($value3 / $totalVote * 100);
Echo '<br>';
Echo 'Value 4:'. $Result4 = round ($value4 / $totalVote * 100);
Echo '<br>';
Echo 'Value 5:'. $Result5 = round ($value5 / $totalVote * 100);
Echo '<br>';
Echo 'Total Value:'. $TotalResult = $result1 + $result2 + $result3 + $result4 + $result5;`
After I add up all the rounding results, I get 101% results. I ever try to using ceil, but I get 102% resuluts.
How do I get 100% of the overall value exactly when everything is summed up?