SPECIAL OFFER        Order and save right now!
20% off with the 729824315 dicscount code for Ultimate Pack and any another product for Delphi from Greatis Programming!

⤷ Convert decimals to binary

The following function converts decimals to binary:

function TForm1.DecToBinStr(N: Integer): string;
var
  S: string;
  i: Integer;
  Negative: Boolean;
begin
  if N<0 then Negative:=True;
  N:=Abs(N);
  for i:=1 to SizeOf(N)*8 do
  begin
    if N<0 then S:=S+'1'
    else S:=S+'0';
    N:=N shl 1;
  end;
  Delete(S,1,Pos('1',S)-1);
  if Negative then S:='-'+S;
  Result:=S;
end;
More for developers
Databases for Amazon Associates
Amazon Categories
Amazon Nodes