AMETEK BPS Series Programming Manual User Manual
Page 59

BPS / MX / RS Series SCPI Programming Manual
AMETEK Programmable Power
Manual P/N 7003-961 Rev. AA
59
If iChar > 9 Then iChar = iChar - 7
c(i) = c(i) * 16 * j + iChar
Next j
Next i
Else
'Retrieve ASC values from four byte input data
'Note: Don't use ASCB or ASCW functions as results will differ
'based on character sets, even on non DCBS Windows
'Retrieve ASC values from four byte input data
For i = 0 To 3
c(i) = Asc(Mid$(sData, i + 1, 1))
Next i
End If
'Get sign bit
sign = ((c(0) And &H80) = &H80)
'Get exponent value less sign bit
expo = (c(0) And &H7F) * 2
'Pick up exponent sign
If (c(1) And &H80) = &H80 Then expo = expo Or 1
'get data less exponent sign bit
c(1) = c(1) And &H7F
mantisse = c(1) * &H10000 + c(2) * &H100 + c(3)
mant_f = mantisse / MANT_MAX
'Process exponent
If (expo <> 0) And (expo <> &HFF) Then
expo = expo - 127
mant_f = mant_f + 1
expo_val = 2 ^ Abs(expo)
If (expo > 0) Then mant_f = mant_f * expo_val
If (expo < 0) Then mant_f = mant_f / expo_val
Else
If (mant_f <> 0) Then
If expo = 0 Then
mant_f = mant_f / EXPO_MAX
Else
mant_f = mant_f * EXPO_MAX
End If
End If
End If
'Append number sign and return value
If sign Then mant_f = -mant_f
StringToIEEEFloat = mant_f
Exit Function
'=============================================================
FloatConvError:
'Conversion errors are truncated to zero
StringToIEEEFloat = 0
Exit Function
End Function