1、 Convert a number to hexadecimal hexadecimal [of_long2hex(long alnumber, integer ai_digit) returns a string] long ll_temp0, ll_temp1 char lc_ret IF ai_digit > 0 THEN ll_temp0 = abs(al_number / (16 ^ (ai_digit - 1))) ll_temp1 = ll_temp0 * (16 ^ (ai_digit - 1)) IF ll_temp0 > 9 THEN lc_ret = char(ll_temp0 + 55) ELSE lc_ret = char(ll_temp0 + 48) END IF RETURN lc_ret + & of_num2hex(al_number - ll_temp1 , ai_digit - 1) END IF RETURN "" // of_longhex(256, 4) returns "0100" // of_longhex(256, 3) returns "100" 2、 Convert an hex string to its decimal equivalent [of_hex2long(as_hex) returns a long] string ls_hex integer i,length long result = 0 length = len(as_hex) ls_hex = Upper(as_hex) FOR i = 1 to length result += & (Pos ('123456789ABCDEF', mid(ls_hex, i, 1)) * & ( 16 ^ ( length - i ) )) NEXT RETURN result

评论