dim val1 as Currency
if divisor <> 0.0 then
val1 = 0.0 / divisor
TextArea1.Text = val1.ToText + EndOfLine
val1 = 1.0 / divisor
TextArea1.Text = TextArea1.Text + val1.ToText + EndOfLine
end if
dim val2 as double
if divisor <> 0.0 then
val2 = 0 / divisor
TextArea1.Text = TextArea1.Text + val2.ToText + EndOfLine
val2 = 1 / divisor
TextArea1.Text = TextArea1.Text + val2.ToText + EndOfLine
end if
Why ? Because Inf and Nan have no representation in an integer - only in doubles
So this is the only reliable way to avoid issues in ALL numeric types
And comparison to 0 or 0.0 is safe in all of them as well
Oh and because INF and Nan in doubles may have many different representations quite legally
See https://en.wikipedia.org/wiki/NaN and https://en.wikipedia.org/wiki/IEEE_floating_point IEEE 754 NaNs are represented with the exponent field filled with ones (like infinity values), and some non-zero number in the significand (to make them distinct from infinity values); this representation allows the definition of multiple distinct NaN values, depending on which bits are set in the significand, but also on the value of the leading sign bit (not all applications are required to provide distinct semantics for those distinct NaN values).