现有0x004EE553DD8B3A000D4E0B772E5EA9528476BA4E2C00665B0D4E1A4F167F0B7A2E000B773C003C0058005800167F0B7A4E00E5651A903E0084762C00A16C1A59115CBA4EFD8010623A4ED89A4B622E00
要转换成
1000111110这样的形式
方法一:
$hex='0x004EE553DD8B3A000D4E0B772E5EA9528476BA4E2C00665B0D4E1A4F167F0B7A2E000B773C003C0058005800167F0B7A4E00E5651A903E0084762C00A16C1A59115CBA4EFD8010623A4ED89A4B622E00'
$hex=StringTrimLeft($hex,2) ;去掉0x
$hex = $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex
$hex = $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex
; 初始化结果
$sBinResult = ""
$sBinResult = StringReplace($hex, "0", "0000")
$sBinResult = StringReplace($sBinResult, "1", "0001")
$sBinResult = StringReplace($sBinResult, "2", "0010")
$sBinResult = StringReplace($sBinResult, "3", "0011")
$sBinResult = StringReplace($sBinResult, "4", "0100")
$sBinResult = StringReplace($sBinResult, "5", "0101")
$sBinResult = StringReplace($sBinResult, "6", "0110")
$sBinResult = StringReplace($sBinResult, "7", "0111")
$sBinResult = StringReplace($sBinResult, "8", "1000")
$sBinResult = StringReplace($sBinResult, "9", "1001")
$sBinResult = StringReplace($sBinResult, "A", "1010")
$sBinResult = StringReplace($sBinResult, "B", "1011")
$sBinResult = StringReplace($sBinResult, "C", "1100")
$sBinResult = StringReplace($sBinResult, "D", "1101")
$sBinResult = StringReplace($sBinResult, "E", "1110")
$sBinResult = StringReplace($sBinResult, "F", "1111")
; 打印结果
;ConsoleWrite("Result is " & $sBinResult)
;MsgBox(0, "Result is", $sBinResult)
方法二:
#include <Array.au3>
$hex='0x004EE553DD8B3A000D4E0B772E5EA9528476BA4E2C00665B0D4E1A4F167F0B7A2E000B773C003C0058005800167F0B7A4E00E5651A903E0084762C00A16C1A59115CBA4EFD8010623A4ED89A4B622E00'
$hex=StringTrimLeft($hex,2) ;去掉0x
$hex = $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex
$hex = $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex & $hex
; 初始化结果
$sBinResult = ""
; 转换为数组,每一位Hex为数组的一个元素
$aTemp = StringSplit($hex, "")
_ArrayDelete($aTemp, 0)
; 开始转换
For $sHex In $aTemp
$sBinResult = $sBinResult & _Hex1ToBin($sHex)
Next
; 打印结果
;ConsoleWrite("Result is " & $sBinResult)
;MsgBox(0, "Result is", $sBinResult)
Func _Hex1ToBin($sHex)
Switch $sHex
Case "0"
$sBin = "0000"
Case "1"
$sBin = "0001"
Case "2"
$sBin = "0010"
Case "3"
$sBin = "0011"
Case "4"
$sBin = "0100"
Case "5"
$sBin = "0101"
Case "6"
$sBin = "0110"
Case "7"
$sBin = "0111"
Case "8"
$sBin = "1000"
Case "9"
$sBin = "1001"
Case "A"
$sBin = "1010"
Case "B"
$sBin = "1011"
Case "C"
$sBin = "1100"
Case "D"
$sBin = "1101"
Case "E"
$sBin = "1110"
Case "F"
$sBin = "1111"
Case Else
;
EndSwitch
Return $sBin
EndFunc
THE END
暂无评论内容