3 ms·
This I knew as well and have used in the past. It's perfectly fine if you do calculations in only one direction, say from amounts to percentages. This algorithm
by fedeb95 4y ago
This I knew as well and have used in the past. It's perfectly fine if you do calculations in only one direction, say from amounts to percentages. This algorithm guarantees you that the sum of percentages (in this case) is 1 regardless of division errors. It doesn't work if you want coherence between amounts and amounts calculated from percentages derived from those amounts, because you're cumulating errors.
Edit: never mind, the code I tested it was wrong, this way works. However the advantage over just increasing precision is unclear to me (in the coherence between back and forth scenario)