| Private Function IEEE754_64(ByRef HexValue() As Byte) As Double
Dim i As Integer
Dim nSign As Integer
Dim nExponent As Double
Dim nMantissa As Double
Dim nPow As Long
Dim nValue As Long
If CBool(HexValue(0) And 128) Then
nSign = -2
Else
nSign = 2
End If
nExponent = ((HexValue(0) And Not 128) * 256 + HexValue(1)) \ 16 - 1023
nValue = (HexValue(1) And &HF&)
nPow = -4
nMantissa = CBool(nValue And 8) * 2 ^ -1 - _
CBool(nValue And 4) * 2 ^ -2 - _
CBool(nValue And 2) * 2 ^ -3 - _
CBool(nValue And 1) * 2 ^ -4 + 1
For i = 2 To 7
nValue = HexValue(i)
If nValue Then
nMantissa = nMantissa - CBool(nValue And 128) * 2 ^ (nPow - 1) - _
CBool(nValue And 64) * 2 ^ (nPow - 2) - _
CBool(nValue And 32) * 2 ^ (nPow - 3) - _
CBool(nValue And 16) * 2 ^ (nPow - 4) - _
CBool(nValue And 8) * 2 ^ (nPow - 5) - _
CBool(nValue And 4) * 2 ^ (nPow - 6) - _
CBool(nValue And 2) * 2 ^ (nPow - 7) - _
CBool(nValue And 1) * 2 ^ (nPow - 8)
End If
nPow = nPow - 8
Next
IEEE754_64 = nSign ^ nExponent * nMantissa
End Function |
| By Renfield |