函数是没有的,不过之前有一位仁兄写的://看我的无限进制转换
//pas
unit DigitUnit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Spin;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Button2: TButton;
SpinEdit1: TSpinEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function Power(Base, Exponent: Integer): Integer;
var
I: Integer;
begin
Result := 1;
for I := 1 to Exponent do
Result := Result * Base;
end; { Power }
const
cScaleChar = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
function DigitToInt(mScale: Byte; mDigit: string): Integer;
var
I, L: Integer;
begin
Result := 0;
L := Length(mDigit);
for I := L downto 1 do
Result := Result + Pred(Pos(mDigit[I], cScaleChar)) * Power(mScale, L - I);
end; { DigitToInt }
function IntToDigit(mScale: Byte; mInt: Integer): string;
var
I, J: Integer;
begin
Result := '';
I := mInt;
while (I >= mScale) do begin
J := I mod mScale;
Result := Copy(cScaleChar, Succ(J), 1) + Result;
I := I div mScale;
end;
Result := Copy(cScaleChar, Succ(I), 1) + Result;
end; { IntToDigit }
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit2.Text := IntToStr(DigitToInt(SpinEdit1.Value, Edit1.Text));
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Edit1.Text := IntToDigit(SpinEdit1.Value, StrToIntDef(Edit2.Text, 0));
end;
end.
//dfm
object Form1: TForm1
Left = 192
Top = 107
Width = 409
Height = 97
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 184
Top = 32
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 0
OnClick = Button1Click
end
object Edit1: TEdit
Left = 136
Top = 8
Width = 121
Height = 21
TabOrder = 1
Text = 'Edit1'
end
object Edit2: TEdit
Left = 272
Top = 8
Width = 121
Height = 21
TabOrder = 2
Text = 'Edit2'
end
object Button2: TButton
Left = 272
Top = 32
Width = 75
Height = 25
Caption = 'Button2'
TabOrder = 3
OnClick = Button2Click
end
object SpinEdit1: TSpinEdit
Left = 8
Top = 8
Width = 121
Height = 22
MaxValue = 255
MinValue = 2
TabOrder = 4
Value = 0
end
end试一下
//pas
unit DigitUnit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Spin;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Button2: TButton;
SpinEdit1: TSpinEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function Power(Base, Exponent: Integer): Integer;
var
I: Integer;
begin
Result := 1;
for I := 1 to Exponent do
Result := Result * Base;
end; { Power }
const
cScaleChar = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
function DigitToInt(mScale: Byte; mDigit: string): Integer;
var
I, L: Integer;
begin
Result := 0;
L := Length(mDigit);
for I := L downto 1 do
Result := Result + Pred(Pos(mDigit[I], cScaleChar)) * Power(mScale, L - I);
end; { DigitToInt }
function IntToDigit(mScale: Byte; mInt: Integer): string;
var
I, J: Integer;
begin
Result := '';
I := mInt;
while (I >= mScale) do begin
J := I mod mScale;
Result := Copy(cScaleChar, Succ(J), 1) + Result;
I := I div mScale;
end;
Result := Copy(cScaleChar, Succ(I), 1) + Result;
end; { IntToDigit }
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit2.Text := IntToStr(DigitToInt(SpinEdit1.Value, Edit1.Text));
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Edit1.Text := IntToDigit(SpinEdit1.Value, StrToIntDef(Edit2.Text, 0));
end;
end.
//dfm
object Form1: TForm1
Left = 192
Top = 107
Width = 409
Height = 97
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 184
Top = 32
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 0
OnClick = Button1Click
end
object Edit1: TEdit
Left = 136
Top = 8
Width = 121
Height = 21
TabOrder = 1
Text = 'Edit1'
end
object Edit2: TEdit
Left = 272
Top = 8
Width = 121
Height = 21
TabOrder = 2
Text = 'Edit2'
end
object Button2: TButton
Left = 272
Top = 32
Width = 75
Height = 25
Caption = 'Button2'
TabOrder = 3
OnClick = Button2Click
end
object SpinEdit1: TSpinEdit
Left = 8
Top = 8
Width = 121
Height = 22
MaxValue = 255
MinValue = 2
TabOrder = 4
Value = 0
end
end试一下
解决方案 »
- delphi 线程里有守护线程这个概念么?
- XP下得到已安装程序的图标?
- 今天有望升星,散分
- HCE400键盘接口的磁卡阅读器需要动态库还是?
- 初学者的头痛问题
- 大家帮忙看看!棘手问题!
- 在C++Builder中调用没有被宝兰封装的API怎么办?
- SQL2000数据库转储截止时间怎样修改
- 用IDUDPServer控件发送UDP包,如果目的IP:PORT不存在,为何会导致该IDUDPServer再也无法接受UDP包?
- 推销自己的homepage, 请您看后在留言本里提提意见。一定给分。
- Delphi中的Grid控件的问题
- 病急乱投医!!!!!为什么Interbase Can not alter a view?怎样解决?急啊!
IntToHex
BinToHex
HexToBin
也许我问的是不太高明,比不得阁下如此聪明高素质的人,但我问一个我不知道的问题有错吗?我更不明白,你怎能这样随意、无端地给别人冠以骗分的美名,我问一个问题,能骗谁的分
子?我异常愤怒!“我希望以后这类骗分的问题少一点”,你以为你是谁,正义光明的化身吗?能
够任意去评判别人吗?
你,这个卑鄙虚伪、厚颜无耻的天涯剑,最后,我只想很认真很认真地对你说一句:你他妈混蛋!
IntToHex 10 to 16
BinToHex 2 to 16
HexToBin 16 to 2
骂得好 已经有不少人在骂他了 呵呵 你可以查看帖子
http://www.csdn.net/Expert/Topicview.asp?id=519449
Format('%*.*X',[6,0,CAP]);//CAP为整型 十进制整型转换为十六进制表示的字符型
StrToInt('$'+edit1.text);//十六进制的字符型转换为十进制的整型/////////////////
IntToBin 10 to 2
IntToHex 10 to 16
BinToHex 2 to 16
HexToBin 16 to 2
to Liusp(夜深千帐灯)
别生气