Home > database >  Binary bytes each sum, overflow is not considered. An algorithm function
Binary bytes each sum, overflow is not considered. An algorithm function

Time:09-27

To convert a 26 Numbers to binary, and speak each byte of the binary addition, overflow part is neglected, the last will get the results into a decimal, zero padding on the left if the result is less than 3
The converted result such as 13926263556020090331094220 to 226

CodePudding user response:

Longlong ll_input1 ll_input2, ll_temp ll_temp2, ll_result
String ls_binary ls_temp, ls_data
Int I

Ls_data='https://bbs.csdn.net/topics/13926263556020090331094220'
Ll_input1=longlong (left (ls_data, 13))
Ll_input2=longlong (mid ls_data, (14))

//converted to hexadecimal 2
Do the while (ll_input1 & gt; 0 or ll_input2 & gt; 0)
If the mod (ll_input1, 2) & gt; 0 then
Ll_input2=10000000000000 + ll_input2
End the if
Ls_binary=string (mod (ll_input2, 2)) + ls_binary
Ll_input1=ll_input1/2
Ll_input2=ll_input2/2
Loop
//fill less than 8 0
Ls_binary=the fill (' 0 ', 8 - mod (len (ls_binary), 8)) + ls_binary

//calculation and
Ll_temp=0
For I=1 to len (ls_binary)/8
Ls_temp=mid (ls_binary, (I - 1) * 8 + 1, 8)

//2 hexadecimal conversion into decimal
Ll_temp2=0
The do while len (ls_temp) & gt; 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 & gt;=256 then ll_temp=ll_temp - 256
Next

Ll_result=ll_temp
  • Related