procedure TForm1.Button1Click(Sender: TObject);
Function DecToBin(value :integer): string;
//将一整数化为二进制数
var temp1, temp2 : integer;
begin
Result := '';
repeat
temp1 := (Value Div 2);
temp2 := (Value Mod 2);
Value := temp1;
Result := inttostr(temp2) + Result;
until temp1 < 2;
if temp1 <> 0 then
Result := inttostr(temp1) + Result;
end;
Function GetHighBitLikeYourSample:string;
var i : integer;
begin
Result := copy(DecToBin(strtoint(Edit1.Text)),1,1);
for i := 1 to length(DecToBin(strtoint(Edit1.Text)))-1do
Result := Result + '0';
end;
begin
try
Showmessage('十进制整数转二进制:'+Edit1.Text +'--->' + DecToBin(strtoint(Edit1.Text))+#13
+ '你示例形式的高位:' + GetHighBitLikeYourSample);
except
Showmessage('参数有误!');
end;
end;