'The Integer type converts "NaN" into 0; Float and Double convert it to NaN
Dim anInteger As Int = "NaN" 'unlike all other strings this one does not a throw an error, which can lead to hard to find bugs
Dim aFloat As Float = "NaN"
Dim aDouble As Double = "NaN"
Log(anInteger & TAB & aFloat & TAB & aDouble)
'Log: 0 NaN NaN
'The following shows how NaN can be used with floats and doubles
Dim vector As String = $"1, 3, 6, spoiled, 1, ?, 7, 10, 9, , 2, 3"$ 'three missing/invalid values
Dim sum As Int = 0
Dim num As Int = 0
Dim v() As String = Regex.Split(",", vector)
Log(v.Length)
For Each s As String In v
If IsNumber(s) = False Then s = "NaN" 'converts "spoiled", "?" and "" to NaN
Dim a As Float = s 'if this is an Integer or Long, the final answer will be wrong!
If a = a Then 'only summed if not NaN => (NaN is NOT equal to itself)
Log(a)
sum = sum + a
num = num + 1
End If
Next
Log(sum & TAB & num & TAB & (sum /num) & TAB & "adjusted sum = " & (v.Length * sum / num))
'Log: 42 9 4.666666666666667 adjusted sum = 56