An example will clear the idea:
number A = 12 number B = 20
I need to divide A per 5 until I dont go less than 5. So I get 3 parts: 5,5 an 2. Now I have to use this result to split B given the weight just calculated. So 20 * (5/12), 20 * (5/12), 20* (2/12) and their sum of course must be exactly equal to B (20 in our case)
I have to do this without losing any precision and trying to have the result as much correct as possible. My example is using int, but I need to do that with decimals as well.(A could be 12.37 and B could be 20.13 for instance) Anyone knows a library or a hint to do that ?