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中简单的调用单元unit实例

Delphi中的memo顶部添加行

Delphi 秒计算分钟、小时函数

Delphi 动态修改exe文件的图标

Delphi d10.x 在安卓app开发中使用jar包的注意事项

Delphi2010中Delphi class explorer妙用

Delphi xe5 android 黑屏的临时解决办法

Delphi 阿拉伯数字转中文汉字数字

Delphi listview 设置固定列宽

Delphi 实现定时功能

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



打赏

取消

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

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

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

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

评论

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