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
Hey @angularsen, I have recently published a pr to create a new Fuel Efficiency unit (#703).
In one of the formulas, there is a division by zero. It happens, that sometimes in our code we have the following call FuelEfficiency.ToUnit(FuelEfficiencyUnit) which throws an exception.
After inspecting the generated code, I have found that nowhere it checks for division by zero, thus the formula 100/x becomes 100/0 and it throws an exception.
I am not sure how propose fixes for this problem, that's why I am writing it here. Right now, I have created an extension method, which first, checks for initial value, and then, if it's non-zero, it calls it's base method.
One more thing, you cannot apply check by zero to all values, because 0 Celsius is not 0 Kelvins and vice versa.