用法如:ShowMessage(IntToStr(15*20));
IntToStr function
Converts an integer to a string.
Unit
SysUtils
Category
numeric formatting routines
Delphi syntax:
function IntToStr(Value: Integer): string; overload;
function IntToStr(Value: Int64): string; overload;
C++ syntax:
extern PACKAGE AnsiString __fastcall IntToStr(int Value);
extern PACKAGE AnsiString __fastcall IntToStr(__int64 Value);
Description
IntToStr converts an integer into a string containing the decimal representation of that number.
它的源碼是匯編的:
function IntToStr(Value: Integer): string;
// FmtStr(Result, '%d', [Value]);
asm
PUSH ESI
MOV ESI, ESP
SUB ESP, 16
XOR ECX, ECX // base: 0 for signed decimal
PUSH EDX // result ptr
XOR EDX, EDX // zero filled field width: 0 for no leading zeros
CALL CvtInt
MOV EDX, ESI
POP EAX // result ptr
CALL System.@LStrFromPCharLen
ADD ESP, 16
POP ESI
end;