Optimized verion of AddThousandSeparator
- From: Tommi Prami <tommi.nospam.prami@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 08 Apr 2008 10:18:31 +0300
Hello,
I was looking for very good way to force thousand separators to Integer (or float) formatted string (in Finlad thousand separators are not normally used in OS level).
I came up with this (found it with google)
function emdAddThousandSeparator(const S: string; Chr: Char = ' '): string;
var
I: Integer;
begin
Result := S;
I := Length(S) - 2;
while I > 1 do
begin
Insert(Chr, Result, I);
I := I - 3;
end;
end;
Then I was thinking that it could be defined like this
function IntToStrT(const AValue: Integer; AThousandsSeparator: Char = ' '): string;
(and one for float(s) maybe)
Maybe this way it would be more efficient, to convert it directly to string with forced thousand separator.
Where I could find routine to modify, pure pascal would do, in which I could implement thousand separator adding. Or does someone have optimized code for this already (or good way to force separators with RTL/VCL, with out changing the Thousand Separator char in ?system.pas/sysutils? (where ever it is, can't remember)...
-TP-
.
- Follow-Ups:
- Re: Optimized verion of AddThousandSeparator
- From: Remy Lebeau \(TeamB\)
- Re: Optimized verion of AddThousandSeparator
- Prev by Date: Re: Tiburón and FastCode
- Next by Date: Re: FastCode - Steps to Build a B&V Release
- Previous by thread: FastCode StrToInt32 B&V 1.1.0
- Next by thread: Re: Optimized verion of AddThousandSeparator
- Index(es):
Relevant Pages
|