I have an dictionary of lists of objects as shown below:
IDictionary<string, IList> MyItemDictionary
IList<double> percentages = new List<double>();
foreach(KeyValuePair<string, IList> pair in MyItemDictionary)
double percentage = (100d/totalItemsCount)*pair.Value.Count;
If your percentage list ends up containing 1.5 + 1.5 + .. + 1.5 = 100.0 and you were to round them into 2 + 2 + .. + 2, you would end up with 134 as the total sum (~67 entries), not 100. The way to fix this, is to distribute the error (134-100=34) among the existing percentages. In this case, you would subtract 1 from 34 of the percentages so you end up with a series of 1 + 2 + 1 + 2 + .. + 2 = 100.0.
To find what "every other" means you simply do int(numberOfPercentages / theError) and that should give you the interval.
Also, you must take care not to subtract anything from your sub 1 percentages.
Oh, and in case all your percentages are sub 1, the problem cannot be solved :-(