|
发表于 2012-8-24 18:37:45
|
显示全部楼层
[au3]MsgBox(0,0,_BitXOR(0xF1F0F3F2FD,0xF5F5F5F5F5))
Func _BitXOR($s_value1, $s_value2 = 0)
Local $s_array = StringSplit($s_value1 & "|" & $s_value2, "|"), $l[$s_array[0] + 1], $ret, $res, $max
For $i = 1 To $s_array[0]
$s_array[$i] = _Binary($s_array[$i])
$l[$i] = StringLen($s_array[$i])
If $l[$i] > $max Then $max = $l[$i]
Next
For $j = 0 To $max - 1
$res = 0
For $i = 1 To $s_array[0]
$res += StringMid($s_array[$i], $l[$i] - $j, 1)
Next
$ret = Mod($res, 2) & $ret
Next
Return _BinToInt($ret)
EndFunc ;==>_BitXOR
Func _Binary($s_number)
Local $b, $t, $max = Int(_LogX($s_number, 2)) + 1
For $i = $max To 0 Step - 1
$t = 2 ^ $i
If $s_number < $t Then
$b &= "0"
ContinueLoop
EndIf
$b &= "1"
$s_number -= $t
Next
If $b = "" Then $b = "0"
Return $b
EndFunc ;==>_Binary
Func _LogX($s_Result, $s_base)
Return Log($s_Result) / Log($s_base)
EndFunc ;==>_LogX
Func _BinToInt($s_string)
Local $res, $t, $j = StringLen($s_string)
For $i = 1 To $j
$t = StringMid($s_string, $i, 1)
If $t <> "0" And $t <> "1" Then Return SetError(-1, 0, -1)
If $t = "1" Then $res += 2 ^ ($j - $i); - ($j-$i>48)
; If $t = "1" Then $res += Int(2 ^ ($j - $i)); - ($j-$i>48)
Next
If $res = "" Then $res = 0
Return $res
EndFunc ;==>_BinToInt
[/au3] |
|