How do you get VB6 to initialize doubles with +infinity, -infinity and NaN?

bugmagnet picture bugmagnet · May 20, 2009 · Viewed 7.3k times · Source

VB6 doesn't appear to make it that easy to store +infinity, -infinity and NaN into double vars. It would help if it could so that I could do comparisons with those values in the context of complex numbers. How?

Answer

YogoZuno picture YogoZuno · May 20, 2009

Actually, there is a MUCH simpler way to get Infinity, -Infinity and Not a Number:

public lfNaN    as Double ' or As Single
public lfPosInf as Double
public lfNegInf as Double

on error resume next    ' to ignore Run-time error '6': Overflow and '11': Division by zero
lfNaN    =  0 / 0       ' -1.#IND
lfPosInf =  1 / 0       '  1.#INF
lfNegInf = -1 / 0       ' -1.#INF

on error goto 0         ' optional to reset the error handler