I have a number and I want to break it down into integers by %
but I want to guarantee that the sum of the breakdown equals the original number. i.e. if there is a rounding error, I want it corrected.
eg
number 998
10% = 100 (rounded up)
30% = 300 (rounded up)
30% = 300 (rounded up)
30% = 300 (rounded up)
for a total of 1000
I can do it the hard way. but is there a simple algorithm ?
but I want to guarantee that the sum of the breakdown equals the original number. i.e. if there is a rounding error, I want it corrected.
eg
number 998
10% = 100 (rounded up)
30% = 300 (rounded up)
30% = 300 (rounded up)
30% = 300 (rounded up)
for a total of 1000
I can do it the hard way. but is there a simple algorithm ?
Comment