Dim a As Integer = 3
Dim b As Integer = 0
Dim c As Integer = a Mod b
Dim d As Double = 3
Dim e As Double = 0
Dim f As Double = d Mod e
Dim i As Integer = 3 Mod 0
Dim j As Double = 3.1 Mod 0
Dim k As Integer = 0.0 Mod 0.0
Dim l As Int64 = 3
Dim m As Int64 = 0
Dim n As Int64 = l Mod m
Actually is one of the worst. It doesn’t even answer the question :-p
The Modulo operation is not an actuall division and can be subject to the conventions applied in number theory. Even the "answer in the lik states “it depends on how you define what it means to mod out by a number”
So 3 Mod 0 could be 3 in modular arithmetic, could be NaN in a simple division, could be an exeption of “divide by 0” or could be 0 as convention. It all deppends on the implementation of the language.
Any way, the Mod operator in xojo some times is modular arithmetic, some times undefined. It should be consice on all cases.
You shouldn’t be expecting any coherent answer from x mod 0 as you shouldn’t be doing it other languages may crash or error if you try this, xojo just kindly allows you to do it without a crash/error so you need to check for >0 before you do the mod.
IF you define X MOD Y strictly as “divide X by Y and return the remainder” then X mod 0 makes no sense as division by 0 makes no sense (ie literally as MOD = X - X\Y will give you errors)
IF you define it as MOD = X - KY for some value of k such that kY <= X then X mod 0 HAS a well defined value since k*Y will always be 0 and X MOD 0 returns X
math stackoverfow has a great discussion of MOD
Xojo COULD simply check X mod Y for the special case of Y= 0 and return X
Right now Xojo opts for the first and so you get undefined behaviour - and you many get DIFFERENT undefined behaviour per platform because the underlying C++ runtimes are not guaranteed to give consistent undefined behaviour