10 进制转 2 进制、16 进制
function IntToBin(Value: LongInt; Size: Integer): String; var i: Integer; begin Result:=''; for i:=Size-1 downto 0 do begin if Value and (1 shl i)<>0 then Result:=Result+'1' else Result:=Result+'0'; end; end; //举例: procedure TForm1.Button1Click(Sender: TObject); var i: Integer; s: string; begin for i := 0 to 255 do begin s := IntToStr(i) + #9; s := s + IntToHex(i,2) + #9; s := s + IntToBin(i,8); Memo1.Lines.Add(s); end; end;
热爱工作,热爱生活,热爱文学