2位十六进制数字转成二进制,还能有更好的写法吗,我写的太烂了 已解决
本帖最后由 ainizm 于 2013-4-30 11:02 编辑请教:2位十六进制数字转成二进制,还能有更好的写法吗,我写的太烂了 $b1 = GUICtrlRead($Input11)
Sleep(100)
$hex = $b1
$str=StringMid($hex,1,1)
switch $str
case '0'
$bin='0000'
case '1'
$bin='0001'
case '2'
$bin='0010'
case '3'
$bin='0011'
case '4'
$bin='0100'
case '5'
$bin='0101'
case '6'
$bin='0110'
case '7'
$bin='0111'
case '8'
$bin='1000'
case '9'
$bin='1001'
case 'a'
$bin='1010'
case 'b'
$bin='1011'
case 'c'
$bin='1100'
case 'd'
$bin='1101'
case 'e'
$bin='1110'
case 'f'
$bin='1111'
endswitch
$str2=StringMid($hex,2,1)
switch $str2
case '0'
$bin2='0000'
case '1'
$bin2='0001'
case '2'
$bin2='0010'
case '3'
$bin2='0011'
case '4'
$bin2='0100'
case '5'
$bin2='0101'
case '6'
$bin2='0110'
case '7'
$bin2='0111'
case '8'
$bin2='1000'
case '9'
$bin2='1001'
case 'a'
$bin2='1010'
case 'b'
$bin2='1011'
case 'c'
$bin2='1100'
case 'd'
$bin2='1101'
case 'e'
$bin2='1110'
case 'f'
$bin2='1111'
endswitch
$bin22 = $bin & $bin2
ToolTip($bin22, 50,0)
Sleep(500) 本帖最后由 netegg 于 2012-11-2 21:31 编辑
#include<math.au3>
Local $a = ['0','1','2','3','4','5','6','7','8','9', 'a','b','c','d','e','f']
For $i = 0 To 15
For $j = 0 To 15
ConsoleWrite(_IntToBin(_HexToInt($a[$i] & $a[$j]))&@cr)
Next
Next 我刚刚试了,这2个函数运行不起来,是不是我的版本低了?
我的版本:3.3.0.0 ,Scite 汉化版本 1.78 忘了更新没更新安装程序里的函数库了,exe的帮助里有 运行提示 _IntToBin
和 _HexToInt 2个出错 本帖最后由 3mile 于 2012-11-3 10:17 编辑
#include <String.au3>
$input = "42"
MsgBox(0,$input,_hextobin($input))
Func _hextobin($number)
Local $b1=Number(Binary('0x'&$number))
Local $out
While $b1
$out&=BitAND($b1,1)
$b1=BitShift($b1,1)
WEnd
Return_StringReverse($out)
EndFunc
页:
[1]