unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
temp:int64;
k:Extended;
z:Extended;
y:int64;
x:double;
j:integer;
i:integer;
begin
temp:=strtoint64('$'+'666696C0');
label1.Caption:=inttostr(temp);
y:=temp;
k:=0;
i:=0;
j:=y div (65536*128);
z:=((2*y)mod(65536*256))/2;
if(j>=127) then begin
for i:=1 to (j-127) do begin
x:=x*2
end;
end
else begin
for i:=1 to (127-j)do begin
x:=x/2 ;
end;
z:=z*2;k:=1;
for i:=1 to 23 do begin
k:=k*2;
x:=x+1/k;
z:=z*2;
end;
x:=x*Z/64;
edit1.text:=floattostr(x); end;end;end.
运行上一段程序时,edit1的text好象没有变化,为什么?
另外,可否请教如何取一个数化为二进制时的某个特定的位
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
temp:int64;
k:Extended;
z:Extended;
y:int64;
x:double;
j:integer;
i:integer;
begin
temp:=strtoint64('$'+'666696C0');
label1.Caption:=inttostr(temp);
y:=temp;
k:=0;
i:=0;
j:=y div (65536*128);
z:=((2*y)mod(65536*256))/2;
if(j>=127) then begin
for i:=1 to (j-127) do begin
x:=x*2
end;
end
else begin
for i:=1 to (127-j)do begin
x:=x/2 ;
end;
z:=z*2;k:=1;
for i:=1 to 23 do begin
k:=k*2;
x:=x+1/k;
z:=z*2;
end;
x:=x*Z/64;
edit1.text:=floattostr(x); end;end;end.
运行上一段程序时,edit1的text好象没有变化,为什么?
另外,可否请教如何取一个数化为二进制时的某个特定的位
解决方案 »
- 求职:delphi研发,亲,有兴趣吗
- cxGrid的PopupEdit如何返回值?
- 如何把treeview里的数据一次性导入数据库?
- 如何降低Delphi开发的程序对系统资源的占用
- 单元与单元之间变量传递,送你十分、祝你十分健康,谢谢参与
- 大家来评论一下
- 那位有软件设计的文档,用到逻辑业务和具体数据处理分离,面向对象?
- 如何让自己的程序生成exe文件,是程序自己组织EXE文件的各个模块,不是res打包释放!
- 有誰寫過條形碼系統?
- 怎样改变messagebox输出的对话框中的按钮上的文字?一定给分!
- 该怎么阻止指针移动时提交插入数据?
- ***********从excel表中读数据到oracle表中的问题,高手指点迷津***********
var
temp: int64;
k: Extended;
z: Extended;
y: int64;
x: double;
j: integer;
i: integer;
begin
temp := strtoint64('$' + '666696C0');
label1.Caption := inttostr(temp);
y := temp;
k := 0;
i := 0;
j := y div (65536 * 128);
z := ((2 * y) mod (65536 * 256)) / 2;
if (j >= 127) then begin
for i := 1 to (j - 127) do begin
x := x * 2
end;
end
else begin
for i := 1 to (127 - j) do begin
x := x / 2;
end;
z := z * 2;
k := 1;
for i := 1 to 23 do begin
k := k * 2;
x := x + 1 / k;
z := z * 2;
end;
x := x * Z / 64; end;
edit1.text := floattostr(x);//要往下移,你上面那段不会执行此语句end;
可以把二进制数,当成字符串,取特定位时,按取字符特定位置的字符,用COPY函数下面是操作二制数的常用方法请参考The following logical operators perform bitwise manipulation on integer operands. For example, if the value stored in X (in binary) is 001101 and the value stored in Y is 100001, the statementZ := X or Y;assigns the value 101101 to Z.Logical (bitwise) operators
Operator Operation Operand types Result type Examples
not bitwise negation integer integer not X
and bitwise and integer integer X and Y
or bitwise or integer integer X or Y
xor bitwise xor integer integer X xor Y
shl bitwise shift left integer integer X shl 2
shr bitwise shift right integer integer Y shr I
The following rules apply to bitwise operators.The result of a not operation is of the same type as the operand.
If the operands of an and, or, or xor operation are both integers, the result is of the predefined integer type with the smallest range that includes all possible values of both types.
The operations x shl y and x shr y shift the value of x to the left or right by y bits, which (if x is an unsigned integer) is equivalent to multiplying or dividing x by 2^y; the result is of the same type as x. For example, if N stores the value 01101 (decimal 13), then N shl 1 returns 11010 (decimal 26). Note that the value of y is interpreted modulo the size of the type of x. Thus for example, if x is an integer, x shl 40 is interpreted as x shl 8 because an integer is 32 bits and 40 mod 32 is 8.