Ron
2007-02-09 22:39:21
Binary to Decimal and Decimal to Binary functions!
Binary to Decimal
// Converts Binary to Decimal.
// Made by Ron. :)
function BinToDec(Str : string) : integer;
var
i : integer;
begin
if(Length(Trim(Str)) = 0)then
Exit;
for i := 1 to Length(Str) do
Result := Result*2 + StrToInt(Str[i]);
end;
Decimal to Binary
// Converts Decimal to Binary.
// Made by Ron. :)
function DecToBin(Number : integer) : string;
begin
while Number > 1 do
begin
Result := IntToStr(Number mod 2)+Result;
Number := Number/2;
end;
Result := '1' + Result;
end;
~Ron