张志峰的博客

水滴石川,积少成多。

导航

delphi inttohex 整型到十六进制

Posted on 2016-05-11 13:21  ╰★张志峰★╮  阅读(682)  评论(0编辑  收藏  举报


inttohex
from delphi help:
Returns the hex representation of an integer.
Unit
SysUtils
Category
numeric formatting routines
Delphi syntax:
function IntToHex(Value: Integer; Digits: Integer): string; overload;
function IntToHex(Value: Int64; Digits: Integer): string; overload;
C++ syntax:
extern PACKAGE AnsiString __fastcall IntToHex(int Value, int Digits);
extern PACKAGE AnsiString __fastcall IntToHex(__int64 Value, int Digits);
Description
IntToHex converts a number into a string containing the number's hexadecimal (base 16) representation. Value is the number to convert. Digits indicates the minimum number of hexadecimal digits to return.
功能说明:该函数用于将“十进制”转换成“十进制”。该函数有二个参数。第一个参数为要转换的十进制数据,第二个参数是指定使用多少位来显示十六进制数据。
  参考实例:
  Edit1.Text := IntToHex('100', 2);
  执行结果,Edit1.Text等于64。
  注意:Delphi没有提供专门的“十六进制”转换为“十进制”的函数。使用StrToInt函数可以实现这个功能。具体代码是:I := StrToInt('$' + '64'); 这时I等于100。加上一个'$'即可将“十六进制”转换为“十进制”。
showmessage(IntTostr(StrToint( '$ '+edit1.text)));