Delphi Tips&Tricks News   Tips   .NET Software   VCL Software   Search   Contacts
Ultimate Pack - special offer!

Ultimate Pack  hot!
Image Editor  new!
Runtime Fusion
Form Designer
Object Inspector
Print Suite Pro
Commented Image
Delphi Toys
WinDowse
Delphi Bonus
TMS Scripter Studio
Form Designer VB
Form Designer .NET

...get more...
for Delphi.NET, C#, VB.NET
for Delphi VCL, BCB 3-6

WinAPI Online
Unix Manual Pages
MegaDetailed.NET
in3steps.com
cdtrrracks.com new!

Blogspot  greatis.blogspot.com

Convert decimals to binary - Mathematics - Tips & Tricks - Greatis Delphi Pages

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;
Related topics
Convert decimals to hexadecimals
Convert hexadecimals to decimals
Convert binary to decimals

For more
Delphi Help

Download source