delphi 十六进制数转换十进制数


本文整理自网络,侵删。

 //自定义函数,转换十六进制数为十进制数 
function HexToInt(Hexa: string): LongWord;
const
ValoresHexa: array['A'..'F'] of integer = (10, 11, 12, 13, 14, 15);
var
nDecimal: LongWord;
nIndex: byte;
begin
nDecimal := 0;
Hexa := Uppercase(Hexa);
for nIndex := Length(Hexa) downto 1 do
if Hexa[nIndex] in ['0'..'9']
then nDecimal := nDecimal + StrToInt(Hexa[nIndex]) *
Trunc(Exp((Length(Hexa) - nIndex) * ln(16)))
else nDecimal := nDecimal + ValoresHexa[Hexa[nIndex]] *
Trunc(Exp((Length(Hexa) - nIndex) * ln(16)));
Result := nDecimal;
end;

相关阅读 >>

Delphi 防止程序重复打开运行

Delphi lockbox 做加密解密

Delphi dll初始化和退出处理

Delphi 程序员的反攻----打击p2p

Delphi 解决timage无法在窗体resize时改变canvas的大小

Delphi fdconnection执行sql execsql

Delphi 用正则表达式检查一个串是否是电信的手机号

Delphi 判断文本是否包含多个关键词之一

Delphi spcomm 接收数据不完整

Delphi 调用viewer-windows10 图像浏览器

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...