How to deal with the sum of rounded percentage not being 100?

前端 未结 5 1865
青春惊慌失措
青春惊慌失措 2020-12-01 05:14

Suppose we have a list of items with an integer:

USA:       3 people
Australia: 2 people
Germany:   2 people

If we calculate the percentage

5条回答
  •  伪装坚强ぢ
    2020-12-01 06:14

    You may "cheat" a bit by summing all the rounded results but the last and giving to the last one the value of 100 - the previous sum...

    In this case, you would have :

    USA = 43
    Aus = 29
    Ger = 28  (100 - (43 + 29))
    

    But that's only a dirty trick... You should rather follow the more honest/accurate solution given by Matt as mine seems to indicate that Germany percentage is less than Australian one.

提交回复
热议问题