
bu benden
Kod: Tümünü seç
////////HEX TO INT/////////////////
Function hexToInt(hexStr: string): longint;
var iErr:integer;
begin
Result := 0;
Val('$' + hexStr, Result, iErr);
end;
Kod: Tümünü seç
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;
Kod: Tümünü seç
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;
Kod: Tümünü seç
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;