You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Allocate function can panic in the if the given ratios are all zero.
This makes sense, since the function will try to divide de given amount in parts of zero.
However, in my application it can make sense to try to allocate zero money, which would be the sum of some item prices, using those same item prices as ratios. Since the items add up to zero, because they are free, you get a call like
I wonder if, in this case, the Allocate function shouldn't return a slice filled with zeros with the same length as the given ratios, instead of panicking while dividing by zero.
On the other hand, Allocating is just another word for dividing, and zero divided by zero should be undefined, and not zero.
The text was updated successfully, but these errors were encountered:
The software must be prepared to deal with these types of situations instead of giving Panic. Returning a slice filled with zeros with the same length as the given ratios or a graceful error seems like good options
I totally agree with @DianaPinheiro, the code must be deterministic.
I would expect zeroes should be returned on a given example. When you try to divide 0 cents to parties, everyone should get 0. @evilnoxx would you have time to work on the PR?
Hello,
The Allocate function can panic in the if the given ratios are all zero.
This makes sense, since the function will try to divide de given amount in parts of zero.
However, in my application it can make sense to try to allocate zero money, which would be the sum of some item prices, using those same item prices as ratios. Since the items add up to zero, because they are free, you get a call like
I wonder if, in this case, the Allocate function shouldn't return a slice filled with zeros with the same length as the given ratios, instead of panicking while dividing by zero.
On the other hand, Allocating is just another word for dividing, and zero divided by zero should be undefined, and not zero.
The text was updated successfully, but these errors were encountered: