function IntPower(mBase, mExponent: Integer): Integer; var I: Integer; begin Result := 1; for I := 1 to mExponent do Result := Result * mBase; end; { IntPower }const cScaleChar = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';function IntToDigit(mNumber: Integer; mScale: Byte; mLength: Integer = 0): string; var I, J: Integer; begin Result := ''; I := mNumber; while (I >= mScale) and (mScale > 1) do begin J := I mod mScale; I := I div mScale; Result := cScaleChar[J + 1] + Result; end; Result := cScaleChar[I + 1] + Result; for I := 1 to mLength - Length(Result) do Result := '0' + Result; end; { IntToDigit }function DigitToInt(mDigit: string; mScale: Byte): Integer; var I: Byte; L: Integer; begin Result := 0; mDigit := UpperCase(mDigit); L := Length(mDigit); for I := 1 to L do Result := Result + (Pos(mDigit[L - I + 1], cScaleChar) - 1) * IntPower(mScale, I - 1); end; { DigitToInt }procedure TForm1.Button1Click(Sender: TObject); var A, B: Integer; begin A := DigitToInt('00100000', 16); ShowMessage(IntToDigit(A, 2)); B := DigitToInt('131072', 10); ShowMessage(IntToDigit(B, 2)); ShowMessage(IntToDigit(A or B, 2)); end;
function IntPower(mBase, mExponent: Integer): Integer; var I: Integer; begin Result := 1; for I := 1 to mExponent do Result := Result * mBase; end; { IntPower }const cScaleChar = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';function IntToDigit(mNumber: Integer; mScale: Byte; mLength: Integer = 0): string; var I, J: Integer; begin Result := ''; I := mNumber; while (I >= mScale) and (mScale > 1) do begin J := I mod mScale; I := I div mScale; Result := cScaleChar[J + 1] + Result; end; Result := cScaleChar[I + 1] + Result; for I := 1 to mLength - Length(Result) do Result := '0' + Result; end; { IntToDigit }function DigitToInt(mDigit: string; mScale: Byte): Integer; var I: Byte; L: Integer; begin Result := 0; mDigit := UpperCase(mDigit); L := Length(mDigit); for I := 1 to L do Result := Result + (Pos(mDigit[L - I + 1], cScaleChar) - 1) * IntPower(mScale, I - 1); end; { DigitToInt }procedure TForm1.Button1Click(Sender: TObject); var A, B: Integer; begin A := DigitToInt('00100000', 16); ShowMessage(IntToDigit(A, 2)); B := DigitToInt('131072', 10); ShowMessage(IntToDigit(B, 2)); ShowMessage(IntToDigit(A or B, 2)); end;
function IntPower(mBase, mExponent: Integer): Integer; var I: Integer; begin Result := 1; for I := 1 to mExponent do Result := Result * mBase; end; { IntPower }const cScaleChar = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';function IntToDigit(mNumber: Integer; mScale: Byte; mLength: Integer = 0): string; var I, J: Integer; begin Result := ''; I := mNumber; while (I >= mScale) and (mScale > 1) do begin J := I mod mScale; I := I div mScale; Result := cScaleChar[J + 1] + Result; end; Result := cScaleChar[I + 1] + Result; for I := 1 to mLength - Length(Result) do Result := '0' + Result; end; { IntToDigit }function DigitToInt(mDigit: string; mScale: Byte): Integer; var I: Byte; L: Integer; begin Result := 0; mDigit := UpperCase(mDigit); L := Length(mDigit); for I := 1 to L do Result := Result + (Pos(mDigit[L - I + 1], cScaleChar) - 1) * IntPower(mScale, I - 1); end; { DigitToInt }procedure TForm1.Button1Click(Sender: TObject); var A, B: Integer; begin A := DigitToInt('00100000', 16); ShowMessage(IntToDigit(A, 2)); B := DigitToInt('131072', 10); ShowMessage(IntToDigit(B, 2)); ShowMessage(IntToDigit(A or B, 2)); end;
function IntPower(mBase, mExponent: Integer): Integer; var I: Integer; begin Result := 1; for I := 1 to mExponent do Result := Result * mBase; end; { IntPower }const cScaleChar = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';function IntToDigit(mNumber: Integer; mScale: Byte; mLength: Integer = 0): string; var I, J: Integer; begin Result := ''; I := mNumber; while (I >= mScale) and (mScale > 1) do begin J := I mod mScale; I := I div mScale; Result := cScaleChar[J + 1] + Result; end; Result := cScaleChar[I + 1] + Result; for I := 1 to mLength - Length(Result) do Result := '0' + Result; end; { IntToDigit }function DigitToInt(mDigit: string; mScale: Byte): Integer; var I: Byte; L: Integer; begin Result := 0; mDigit := UpperCase(mDigit); L := Length(mDigit); for I := 1 to L do Result := Result + (Pos(mDigit[L - I + 1], cScaleChar) - 1) * IntPower(mScale, I - 1); end; { DigitToInt }procedure TForm1.Button1Click(Sender: TObject); var A, B: Integer; begin A := DigitToInt('00100000', 16); ShowMessage(IntToDigit(A, 2)); B := DigitToInt('131072', 10); ShowMessage(IntToDigit(B, 2)); ShowMessage(IntToDigit(A or B, 2)); end;
var
I: Integer;
begin
Result := 1;
for I := 1 to mExponent do Result := Result * mBase;
end; { IntPower }const
cScaleChar = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';function IntToDigit(mNumber: Integer; mScale: Byte;
mLength: Integer = 0): string;
var
I, J: Integer;
begin
Result := '';
I := mNumber;
while (I >= mScale) and (mScale > 1) do begin
J := I mod mScale;
I := I div mScale;
Result := cScaleChar[J + 1] + Result;
end;
Result := cScaleChar[I + 1] + Result;
for I := 1 to mLength - Length(Result) do Result := '0' + Result;
end; { IntToDigit }function DigitToInt(mDigit: string; mScale: Byte): Integer;
var
I: Byte;
L: Integer;
begin
Result := 0;
mDigit := UpperCase(mDigit);
L := Length(mDigit);
for I := 1 to L do
Result := Result + (Pos(mDigit[L - I + 1], cScaleChar) - 1) *
IntPower(mScale, I - 1);
end; { DigitToInt }procedure TForm1.Button1Click(Sender: TObject);
var
A, B: Integer;
begin
A := DigitToInt('00100000', 16);
ShowMessage(IntToDigit(A, 2));
B := DigitToInt('131072', 10);
ShowMessage(IntToDigit(B, 2));
ShowMessage(IntToDigit(A or B, 2));
end;
var
I: Integer;
begin
Result := 1;
for I := 1 to mExponent do Result := Result * mBase;
end; { IntPower }const
cScaleChar = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';function IntToDigit(mNumber: Integer; mScale: Byte;
mLength: Integer = 0): string;
var
I, J: Integer;
begin
Result := '';
I := mNumber;
while (I >= mScale) and (mScale > 1) do begin
J := I mod mScale;
I := I div mScale;
Result := cScaleChar[J + 1] + Result;
end;
Result := cScaleChar[I + 1] + Result;
for I := 1 to mLength - Length(Result) do Result := '0' + Result;
end; { IntToDigit }function DigitToInt(mDigit: string; mScale: Byte): Integer;
var
I: Byte;
L: Integer;
begin
Result := 0;
mDigit := UpperCase(mDigit);
L := Length(mDigit);
for I := 1 to L do
Result := Result + (Pos(mDigit[L - I + 1], cScaleChar) - 1) *
IntPower(mScale, I - 1);
end; { DigitToInt }procedure TForm1.Button1Click(Sender: TObject);
var
A, B: Integer;
begin
A := DigitToInt('00100000', 16);
ShowMessage(IntToDigit(A, 2));
B := DigitToInt('131072', 10);
ShowMessage(IntToDigit(B, 2));
ShowMessage(IntToDigit(A or B, 2));
end;
// uses IdGlobal
procedure TForm1.Button1Click(Sender: TObject);
begin
Caption := IntToBin($00100000);
end;
var
I: Integer;
begin
Result := 1;
for I := 1 to mExponent do Result := Result * mBase;
end; { IntPower }const
cScaleChar = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';function IntToDigit(mNumber: Integer; mScale: Byte;
mLength: Integer = 0): string;
var
I, J: Integer;
begin
Result := '';
I := mNumber;
while (I >= mScale) and (mScale > 1) do begin
J := I mod mScale;
I := I div mScale;
Result := cScaleChar[J + 1] + Result;
end;
Result := cScaleChar[I + 1] + Result;
for I := 1 to mLength - Length(Result) do Result := '0' + Result;
end; { IntToDigit }function DigitToInt(mDigit: string; mScale: Byte): Integer;
var
I: Byte;
L: Integer;
begin
Result := 0;
mDigit := UpperCase(mDigit);
L := Length(mDigit);
for I := 1 to L do
Result := Result + (Pos(mDigit[L - I + 1], cScaleChar) - 1) *
IntPower(mScale, I - 1);
end; { DigitToInt }procedure TForm1.Button1Click(Sender: TObject);
var
A, B: Integer;
begin
A := DigitToInt('00100000', 16);
ShowMessage(IntToDigit(A, 2));
B := DigitToInt('131072', 10);
ShowMessage(IntToDigit(B, 2));
ShowMessage(IntToDigit(A or B, 2));
end;
var
I: Integer;
begin
Result := 1;
for I := 1 to mExponent do Result := Result * mBase;
end; { IntPower }const
cScaleChar = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';function IntToDigit(mNumber: Integer; mScale: Byte;
mLength: Integer = 0): string;
var
I, J: Integer;
begin
Result := '';
I := mNumber;
while (I >= mScale) and (mScale > 1) do begin
J := I mod mScale;
I := I div mScale;
Result := cScaleChar[J + 1] + Result;
end;
Result := cScaleChar[I + 1] + Result;
for I := 1 to mLength - Length(Result) do Result := '0' + Result;
end; { IntToDigit }function DigitToInt(mDigit: string; mScale: Byte): Integer;
var
I: Byte;
L: Integer;
begin
Result := 0;
mDigit := UpperCase(mDigit);
L := Length(mDigit);
for I := 1 to L do
Result := Result + (Pos(mDigit[L - I + 1], cScaleChar) - 1) *
IntPower(mScale, I - 1);
end; { DigitToInt }procedure TForm1.Button1Click(Sender: TObject);
var
A, B: Integer;
begin
A := DigitToInt('00100000', 16);
ShowMessage(IntToDigit(A, 2));
B := DigitToInt('131072', 10);
ShowMessage(IntToDigit(B, 2));
ShowMessage(IntToDigit(A or B, 2));
end;