HexToInt - IntToBin - BinToInt - IntToRoman
mege12.05.2004 - 09:38:32
hextoint dönüşümü esasında eskiden beri döngü ile yaptığım işi delphi kolaycana yapıyormuş. vaybe :D görünce hemen denedim ve muvaffak oldum.

bu benden
////////HEX TO INT/////////////////
Function hexToInt(hexStr: string): longint;
var iErr:integer;
begin
Result := 0;
Val('$' + hexStr, Result, iErr);
end;


bunlar ise esinlendiğim siteden

function IntToBin(Value: LongInt;
Digits: Integer): String;
var
i: Integer;
begin
Result:='';
for i:=Digits downto 0 do
if Value and (1 shl i)<>0 then
Result:=Result + '1'
else
Result:=Result + '0';
end;


function BinToInt(Value: String): LongInt;
var i: Integer;
begin
Result:=0;
//remove leading zeros
while Copy(Value,1,1)='0' do
Value:=Copy(Value,2,Length(Value)-1);
//do the conversion
for i:=Length(Value) downto 1 do
if Copy(Value,i,1)='1' then
Result:=Result+(1 shl (i-1));
end;


function IntToRoman(Value: LongInt): String;
const
Arabics: Array[1..13] of Integer =
(1,4,5,9,10,40,50,90,100,400,500,900,1000);
Romans: Array[1..13] of String =
('I','IV','V','IX','X','XL',
'L','XC','C','CD','D','CM','M');
var
i: Integer;
begin
for i := 13 downto 1 do
while (Value >= Arabics[i]) do begin
Value := Value - Arabics[i];
Result := Result + Romans[i];
end;
end;


Kaynak : http://delphi.about.com/library/weekly/aa010599.htm
 
gkimirti12.05.2004 - 09:46:30
ewt hocam bende StrToInt in boyle bir yetenegi oldugunu gorunce sasırmıstım:)
 
mege12.05.2004 - 10:04:48
ewt hocam bende StrToInt in boyle bir yetenegi oldugunu gorunce sasırmıstım:)


hocam strtoint kullanınca sürekli exception oluşturuyor. try except koymaktansa bende val ile yaptım. hem daha kısa oldu :D .
 
NOT : Bu sayfa google'un siteyi indekslemesi içindir. www.delphiturkiye.com/forum/ adresini kullanınız!
1998-2006 www.delphiturkiye.com