Integer divide by zero returns null instead of error or infinity
Our divide by zero behavior is currently inconsistent and should be cleaned up
Current Results
0 / 0 == NaN
0.0 / 0.0 = NaN
1 / 0 == null
1.1 / 0 == Infinity
-1.1 / 0 == -Infinity
Expected Behavior
There are a couple of reasonable solutions (null isn't one of them):
- return an error
- return Infinity or -Infinity
I'd argue for 2, since we're already returning NaN for 0/0, effectively promoting the integer operands to a floating point result, and this would be the equivalent.
Screenshots
Additional context
As an aside, when testing this I (re)discovered that there's no way to get a floating point 1.0. It will always get demoted back to an integer which is kind of taking the whole polymorphism thing to an extreme.
Happy with either approach 1 or 2 as you describe.
I'm interested in the floating point vs integer question but maybe this needs a separate discussion either via forum or a separate GitHub issue?
@ostephens Thanks for the feedback. On reflection, I think the 1.0 behavior is a symptom of https://github.com/OpenRefine/OpenRefine/issues/5469#issuecomment-1334611706
@tfmorris is it possible I work on this issue or it has already been assigned to someone else (talking about the division by zero and not the 1.0 getting demoted to an integer).
@Kurocifer It's actually assigned to me, as you can see in the upper right of the page, but since you've created a PR, I'll review it.