Shl、Shr、Xor、Not是什么意思啊(100分)

  • 主题发起人 主题发起人 ysp_1984
  • 开始时间 开始时间
Y

ysp_1984

Unregistered / Unconfirmed
GUEST, unregistred user!
Shl、Shr、Xor、Not是什么意思啊?怎样写出Shl、Shr、Xor、Not 的数学表示法;
 
Shl左移
Shr右移
Xor异或
Not取反


Logical (bitwise) operators
--------------------------
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 statement

Z := X or Y;

assigns the value 101101 to Z.

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 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,
 
随便找一个基础的delphi书籍,上边有的
 
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
 
我知道意思,怎么表示啊?
 
查查帮助嘛:
shl - 向左移位 shr - 向右移位 xor - 异或 not - 取非
数据表示法指什么?
 
建议你去看看有关汇编的书
 
var
tt: Integer;
x, y: Integer;
begin
x := $10;
y := $20;
tt := x shl 1;
tt := x shr 1;
tt := x xor y;
tt := not x;
...
end;
 
给个例子看看 ,用数学表示法.
 
详细解释一下啊,我帮你提前,
这些我也懂:
shl:高位、低位左移
Shr:右移
Xor:异或。 判断相同的话,值为零,不同的话使用异或的值。
Not : not 1=0 ,not 0=1 了。
不过我也不能深入的解释,
 
var
tt: Integer;
x, y: Integer;
begin
x := $10;
y := $20;
tt := x shl 1;
tt := x shr 1;
tt := x xor y;
tt := not x;
中的 x := $10;和X:=10有什么区别啊
 
加$表示16进制,不加为10进制
 
哦谢谢大家了.
 
x := $10; //十六进制
相当与
x:=16; //十进制

这年头,骗点分不容易啊。
 
多人接受答案了。
 
后退
顶部