Home > database >  How do I in pb6.5 binary code into hexadecimal code, be urgent!!!!
How do I in pb6.5 binary code into hexadecimal code, be urgent!!!!

Time:10-05

How to convert binary code within pb6.5 hexadecimal code, please expert advice, thank you!!!!!

CodePudding user response:

Write a function by yourself.
Such as: 1101
Use the following format converted to decimal
1 + 1 * 2 * 2 ^ 3 ^ 2 + 0 * 2 ^ ^ 0 1 + 1 * 2=13

Then the decimal for hexadecimal
13=0 xd

CodePudding user response:

A function to you, use it directly! Pb6.5 should be able to use it,
===========================================
//define the parameter string s_bin//the hexadecimal number string type 2
//return a string s_hex


Int li_slen li_loop, li_mod
String s_hex
If upper (left (s_bin, 1))='B' then s_bin=mid (s_bin, 2)
Li_slen=len (s_bin)
Li_mod=mod (li_slen, 4)
Choose a case li_mod
Case 1
S_bin='000' + s_bin
Case 2
S_bin='00' + s_bin
Case 3
S_bin='0' + s_bin
The end choose
For li_loop=1 to li_slen step 4
Choose case mids (s_bin li_loop, 4)
Case '0000'
S_hex=s_hex + '0'
Case '0001'
S_hex=s_hex + '1'
Case '0010'
S_hex=s_hex + '2'
Case '0011'
S_hex=s_hex + '3'
Case '0100'
S_hex=s_hex + '4'
Case '0101'
S_hex=s_hex + '5'
Case '0110'
S_hex=s_hex + '6'
Case '0111'
S_hex=s_hex + '7'
Case '1000'
S_hex=s_hex + '8'
Case '1001'
S_hex=s_hex + '9'
Case '1010'
S_hex=s_hex + 'A'
Case '1011'
S_hex=s_hex + 'B'
Case '1100'
S_hex=s_hex + 'C'
Case '1101'
S_hex=s_hex + 'D'
Case '1110'
S_hex=s_hex + 'E'
Case '1111'
S_hex=s_hex + 'F'
In case the else
Return "- 1
"The exit
The end choose
Next

Return s_hex

CodePudding user response:

There is a problem please GOOGLE and BAIDU
  • Related