Some other tools and languages provide a Divide(numerator, denominator, default) function that returns the specified default value when the denominator is 0.
So, I created my own version in the Wolfram langage.
Options[tdyDivide] = {
"default" -> 0.,
"precision" -> 2
};
tdyDivide[numerator_?NumericQ, denominator_?NumericQ,
OptionsPattern[]] :=
N[
If[
denominator != 0.,
numerator / denominator,
OptionValue["default"]
],
OptionValue["precision"]
];
I'm still building unit tests for this. So, if you find any issues, please let me know.
thanks