Algorithm Math Delphi

{---------------Sayıya çevirme rutini-----------------------}
const
BIRLER: array[0..9] of string=('', 'Bir', 'İki', 'Üç', 'Dört', 'Beş', 'Altı',
'Yedi', 'Sekiz', 'Dokuz');
ONLAR : array[0..9] of string=('', 'On', 'Yirmi', 'Otuz', 'Kırk', 'Elli', 'Altmış',
'Yetmiş', 'Seksen', 'Doksan');
DIGER : array[0..5] of string=('', 'Bin', 'Milyon', 'Milyar', 'Trilyon', 'Katrilyon');
function SmallNum(N: Integer): string;
var
S: string[3];
begin
Result := '';
S := IntToStr(N);
if (Length(S)=1) then
S := '00' + S
else if (Length(S)=2) then
S := '0' + S;
if S[1]<>'0' then
if S[1]<>'1' then
Result := BIRLER[StrToInt(S[1])] + 'Yüz'
else
Result := 'Yüz';
Result := Result + ONLAR[StrToInt(S[2])];
Result := Result + BIRLER[StrToInt(S[3])];
end;
function NumStr(Num: Extended): string; export;stdcall;
var
kurus,i, j, n, Nm: Integer;
S, Sn: string;
begin
S := FormatFloat('0', Num);
Sn := '';
if Num = 0 then
Sn := 'Sifir'
else if Length(S) < 4 then
Sn := SmallNum(trunc(Num))
else
begin
I := 1;
J := Length(S) mod 3;
if J=0 then
begin
J := 3;
N := Length(S) div 3 - 1;
end
else
N := Length(S) div 3;
while i begin
Nm := StrToInt(Copy(S, I, J));
if (Nm=1) and (N=1) then
begin
Nm := 0;
Sn := Sn + SmallNum(Nm) + Diger[N];
end;
if Nm<>0 then
Sn := Sn + SmallNum(Nm) + Diger[N];
I := I + J;
J := 3;
N := N - 1;
end;
end;
Result := Sn;
Kurus:=Round(Frac(Num)*100);
if (kurus > 0) then
begin
if (Result <> '') then Result:= Result +' YTL ' + NumStr(Kurus) + ' Krş';
end;
end;