unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    Button1: TButton;
    Button2: TButton;
    Label2: TLabel;
    Label3: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
function IntToBinF(x:integer;k:integer):string;
var s:string;
begin
  s:='';
  repeat
     if x mod 2=0 then s:='0'+s else s:='1'+s;
     x:=x div 2;
     k:=k-1;
     if (x>0)and (k=0) then k:=k+1; {1}
  until k=0;
  Result:=s;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 Label1.Caption:=IntToHex( StrtoInt(Edit1.Text),4);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 Label2.Caption:=IntToBinF( StrtoInt(Edit1.Text),8);
end;

end.
