From what I can see, this has been the behavior for a looooong time; in the logs I see it has been like this in C# from the very beginning (2008), when we changed from PHP to C#.
Interestingly it seems that in PHP the behavior was what you propose; I canāt remember what the reason was to change it (and canāt find anything about it in the logs), but it seems we have done so consistently (for all arithmetic operations). Maybe Wim remembers?
I agree that I would expect null/1 to be null as well, but for other operators (null+1, null-1, null*1) I am less sure. And what about things like sum? And avg?
I agree with Helena that changing this could have unwanted consequences in many places, so it feels like something that we cannot change overnight even if we wanted to. Maybe for ādivā alone it wouldnāt be so bad, but for the others it probably would.
I came to the same conclusion as Erik-Jan. Itās been that way forever, and consistently implemented that way for all/most the arithmetic operators.
Iām not sure that it āshouldā be one way or the other. Either choice has its pros and cons. It seems like that in Javascript and in PHP null/1 = 0. In C# (sort of - when you use Nullable for example) and in SQL null/1 = null.
It comes down to the definition for null that you choose. Is it āthe absence of a valueā, is it āan invalid valueā, is it āstating that there is a value but you donāt know which one (yet)ā? Javascript distincts 0, null, undefined and NaN. In the C programming language, if I remember correctly, NULL is actually defined as a constant with the value 0.
I donāt remember why exactly we chose the JS/PHP way over the C#/SQL way in 2008 and couldnāt find any notes on this topic with a quick search. Changing it could break a lot. It seems quite doable however to create a NullableDiv function in a plug-in.
Hi Wim, thanks for the explanation and context. A nullable Div (and then I guess also a nullable Mult, Add and Sub) sounds very good. Iāll create an SR for it. I keep the post open, so as soon as we have a new plug-in (revision) to post it here.