Global $hData = '36C1C008'
Global $iEx, $iIntData, $fData
Global $iDec
For $i = StringLen($hData) - 1 To 1 Step -2
$fData &= StringMid($hData, $i, 2)
Next
$hData = _NumberToBinary('0x' & $fData)
ConsoleWrite($hData & @CRLF)
$iEx = _BinaryToDec(StringMid($hData, 2, 8)) - 127
For $i = 23 To $iEx
$hData &= '0'
Next
$iIntData = '1' & StringMid($hData, 10, $iEx)
$iDec = _BinaryToDec($iIntData) + switchbinary(StringMid($hData, $iEx + 10))
MsgBox(0, 0, $iDec)
Func switchbinary($data)
Local $iRet = 0
Local $Len = StringLen($data)
For $i = $Len To 1 Step -1
$iS = Number(StringMid($data, $i, 1)) * 2 ^ (-1 * $i)
$iRet += $iS
Next
Return StringFormat('%.02f', $iRet)
EndFunc ;==>switchbinary
Func _NumberToBinary($iNumber)
Local $iTopBit, $sBinString = ""
If $iNumber < -2147483648 Or $iNumber > 4294967295 Then Return SetError(1, 0, "")
If $iNumber > 2147483647 Or $iNumber < 0 Then
$iTopBit = 1
Else
$iTopBit = 0
EndIf
Local $iUnsignedNumber = BitAND($iNumber, 0x7FFFFFFF)
Do
$sBinString = BitAND($iUnsignedNumber, 1) & $sBinString
$iUnsignedNumber = BitShift($iUnsignedNumber, 1)
Until Not $iUnsignedNumber
Return $iTopBit & StringRight("000000000000000000000000000000" & $sBinString, 31)
EndFunc ;==>_NumberToBinary
Func _BinaryToDec($sBinStr)
Local $sDecStr = 0
If Not StringRegExp($sBinStr, "^[01]{1,63}$") Then Return SetError(1, 0, "")
For $i = 1 To StringLen($sBinStr)
$sDecStr = $sDecStr * 2 + StringMid($sBinStr, $i, 1)
Next
Return $sDecStr
EndFunc ;==>_BinaryToDec
|