最新消息:

十六进制转二进制

autoit 永恒心锁 1302浏览 0评论

现有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)

方法二:

<blockquote><font face="Verdana, Helvetica, Arial, sans-serif"><span style="font-size: 12px; line-height: normal;">#include <Array.au3></span></font>

方法三:

#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

 

免责声明:根据《计算机软件保护条例》第十七条规定“为了学习和研究软件内含的设计思想和原理,通过安装、显示、传输或者存储软件等方式使用软件的,可以不经软件著作权人许可,不向其支付报酬。”您需知晓本站所有内容资源均来源于网络,仅供用户交流学习与研究使用,版权归属原版权方所有,版权争议与本站无关,用户本人下载后不能用作商业或非法用途,需在24个小时之内从您的电脑中彻底删除上述内容,否则后果均由用户承担责任;如果您访问和下载此文件,表示您同意只将此文件用于参考、学习而非其他用途,否则一切后果请您自行承担,如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。丨本站为个人博客非盈利性站点,所有软件信息均来自网络,所有资源仅供学习参考研究目的,并不贩卖软件,不存在任何商业目的及用途。丨本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » 十六进制转二进制

您必须 登录 才能发表评论!