Change evaluation order for calculating percentage

Rounding errors are introduced when calculating the percentage when the total is 100 (for example if percentages have already been calculated). Calculating `total/100` first eliminates the error in this case.