Here is code to create all special value types for a double
Code:
Option Explicit
Public Declare Sub CopyMemory Lib "kernel32" Alias _
"RtlMoveMemory" (destination As Any, source As Any, _
ByVal length As Long)
Public Function PosQNaN() As Double
'returns positive qnan
Dim Oput As Double
Dim l(1 To 2) As Long
l(1) = 0
l(2) = &H7FF80000
CopyMemory Oput, l(1), 8
PosQNaN = Oput
End Function
Public Function NegQNaN() As Double
'returns negative qnan
Dim Oput As Double
Dim l(1 To 2) As Long
l(1) = 1
l(2) = &HFFF80000
CopyMemory Oput, l(1), 8
NegQNaN = Oput
End Function
Public Function Indeterminate() As Double
'returns an indeterminate
Dim Oput As Double
Dim l(1 To 2) As Long
l(1) = 0
l(2) = &HFFF80000
CopyMemory Oput, l(1), 8
Indeterminate = Oput
End Function
Public Function PosInfinity() As Double
'returns a positive infinity
Dim Oput As Double
Dim l(1 To 2) As Long
l(1) = 0
l(2) = &H7FF00000
CopyMemory Oput, l(1), 8
PosInfinity = Oput
End Function
Public Function NegInfinity() As Double
'returns a negative infinity
Dim Oput As Double
Dim l(1 To 2) As Long
l(1) = 0
l(2) = &HFFF00000
CopyMemory Oput, l(1), 8
NegInfinity = Oput
End Function