16进制:$//strtoint()//IntToHex
解决方案 »
- 进来看下图片效果,看该如何做??
- 用ADODataset或ADOQuery如何实现查找功能??
- 请教高手,如何将控件的name编号进行操作呢???
- delphi的緩存更新機制是否有問題?為什麼連續增幾行後,在DBGrid裡總是出現重復的記錄顯示?
- 求救,关于用DELPHI6开发WEBSERVICE的问题
- 谁会用bsSkinDbGrid?
- 给我几个很棒的源码(最好是DELPHI数据库程序)下载的站点吧!
- 菜鸟急救:DBNavigator?????????????
- 怎么建立一个文件夹?
- 如何制作出这样的报表?
- 在flash动画中夹杂木马程序的可能性!!!
- 我做了个报表,预览时的汉字显示总是有的挤在一起,有的又离的很远,打印时却没问题。
delphi中没有2进制的类或函数吧?要用就自己写了
function DecToBinStr(n: integer): string;
var
S: string;
i: integer;
Negative: boolean;
begin
if n < 0 then
Negative := true
else
Negative := False; n := Abs(n);
for i := 1 to SizeOf(n) * 8 do
begin
if n < 0 then
S := S + '1'
else
S := S + '0'; n := n shl 1;
end;
Delete(S,1,Pos('1',S) - 1);//remove leading zeros
if Negative then
S := '-' + S;
Result := S;
end;如何把一个16进制字符转换为10进制
(1)方法1
Function HexToDec(const Value :Integer ) : string;
var
s : string;
begin
s := '$' + IntToStr(Value);
Result := InToStr(StrToInt(s));
end;(2)方法2
Funtion HexToDec(const Value :Integer) : string;
CONST HEX : ARRAY['A'..'F'] OF INTEGER = (10,11,12,13,14,15);
VAR
str : String;
In : Integer;
i : integer;
BEGIN
Str := UpperCase(IntToStr(Value));
Int := 0;
FOR i := 1 TO Length(str) DO
IF str[i] < 'A' THEN
Int := Int * 16 + ORD(str[i]) - 48
ELSE
Int := Int * 16 + HEX[str[i]];
Result := IntToStr(Int);
end;
这样的答案你是否可以给我加分呢?
StrToInt('$'+'B4')
10->16
IntToHex 函数
16->2
HexToBin 函数
shl的运行结果有问题,不过我已经自己搞定了10到2的转换
你的16到10的方法非常有缺陷,因为你用integer作为参数,根本就不能输a,b,c,d,e,f这几个数,所以不行。
系统提供的strToInt,IntToHex,HexToBin使用是不能运行通过,说是没有作为override的原函数,莫名其妙,我直接拷贝的他的例子来运行都这个样子
Math;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;
if mLength > 0 then
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;
L := Length(mDigit);
for I := 1 to L do
Result := Result + (Pos(mDigit[L - I + 1], cScaleChar) - 1) *
Trunc(IntPower(mScale, I - 1));
end; { DigitToInt }