When using the formula below
if ((theFlag div theMask) mod 2) = 0 then
return false
else
return true
end if
I have enum opts (theMask) that are 0 value
Will I have issues with the formula and the
Divide by zero issue?
I guess I should put a safety check in the to test if theMask is zero? And then check if theFlag is also zero?i
0 div or 0 mod anything will be zero, but yes, there will be an error if you try to divide by zero. Depending on what you want the safety checks to do, you could just short-circuit the statement by doing something like return (theMask ≠ 0) and ((theFlag div theMask) mod 2) = 0 - note that you don’t need to use an if statement to return true/false since the comparison already evaluates to a boolean.