將一個26數字轉換成二進制,并講該二進制數的每個位元組相加,溢位部分忽略不計,最后將得到的結果化為十進制,如果結果不足3位,左邊補零
如 13926263556020090331094220 轉換后結果為226
uj5u.com熱心網友回復:
longlong ll_input1,ll_input2,ll_temp,ll_temp2,ll_resultstring ls_binary,ls_temp,ls_data
int i
ls_data = '13926263556020090331094220'
ll_input1 = longlong(left(ls_data,13))
ll_input2 = longlong(mid(ls_data,14))
//轉換成2進制
do while (ll_input1 > 0 or ll_input2 > 0 )
if mod(ll_input1,2) > 0 then
ll_input2 = 10000000000000 + ll_input2
end if
ls_binary = string(mod(ll_input2,2)) + ls_binary
ll_input1 = ll_input1 / 2
ll_input2 = ll_input2 / 2
loop
//不足8位補0
ls_binary = fill('0',8 - mod(len(ls_binary),8)) + ls_binary
//計算和
ll_temp = 0
for i = 1 to len(ls_binary)/8
ls_temp = mid(ls_binary,(i - 1) * 8 + 1,8)
//2進制轉換成10進制
ll_temp2 = 0
do while len(ls_temp) > 0
ll_temp2 = ll_temp2 * 2 + long(left(ls_temp,1))
ls_temp = mid(ls_temp,2)
loop
ll_temp = ll_temp + ll_temp2
if ll_temp >=256 then ll_temp = ll_temp - 256
next
ll_result = ll_temp
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/82608.html
標籤:腳本語言
上一篇:懸賞 做讀卡器介面
下一篇:新手求助
