Delphi Shl与Shr 移位操作介绍
格式:操作数 Shl/Shr 移动位数
说明:操作数与返回值都是整数
例子:16(10) = 10000(2)
16(10) Shr 1 = 10000(2) Shr 1 = 1000(2) = 8(10)
16(10) Shr 2 = 10000(2) Shr 2 = 100(2) = 4(10)
说明:一个整数(I)按位左移一位,相当于把它乘以2,即 I * 2
一个整数(I)按位右移一位,相当于把它除以2,即 I Div 2
一个整数(I)按位左移2 位,相当于把它乘以2再乘2,即 (I * 2) * 2
一个整数(I)按位右移2 位,相当于把它除以2再除2,即 (I Div 2) Div 2
分析:引用我们最常用的十进制来说明,假如有一个数16,在十进制中住右移一位,结果剩1,左移一位即是160,相当于16 Div 10 和 16 * 10;
同理,在二进制中整除和乘的是2。
得到如下:结果只是操作数与进制数之间的操作了。
相关文档:
1. 命令的接收者
{《HeadFirst设计模式》之命令模式 }
{ 本单元中的类为命令的接收者 }
{ 编译工具 :Delphi7.0 }
{ 联系方式 :xshlife@163.com }
unit uReceiveObject;
interface
type
TLight = class(TObject)
private
FLocation: String;
public
constru ......
没有应用状态模式的代码
1. 工程文件
program Project1;
{$APPTYPE CONSOLE}
uses
uGumballMachine in 'uGumballMachine.pas';
var
aGumballMachine: TGumballMachine;
begin
aGumballMachine := TGumballMachine.Create(5);
aGumballMachine.InsertQuarter;
aGumballMachine.TurnCrank;
Writeln; ......
构建 Windows SOAP 服务器应用程序
首先在 Windows 上构建服务器,然后在 Linux 上构建客户机。(如果需要,可以使用其它方法 — 或者将它们全部构建在 Windows 或 Linux 上。)对于 Windows SOAP 服务器,启动 Delphi 7 Enterprise,执行 File -> New -> Other,转至对象资源库(Object Repository)的 ......