shr 右移测试

fdword :DWORD;
procedure TForm10.btn1Click(Sender: TObject);
 var  temp:DWORD;
begin
  fdword :=786627;    //786627  11000000000011000011
  temp := fdword shr (1*8);    //
  ShowMessage(IntToStr(temp)); //3072   110000000000
  temp := fdword shr (2*8);
  ShowMessage(IntToStr(temp));  //12  1100
  temp := fdword shr (3*8);
  ShowMessage(IntToStr(temp));  //0   0
  temp := fdword shr (4*8);
  ShowMessage(IntToStr(temp));//786627    11000000000011000011

  temp := fdword shr (5*8);  //右移 5个字节  提示错误
  //[DCC Error] Unit10.pas(41): E1012 Constant expression violates subrange bounds
  //(DCC错误)Unit10.pas(41):E1012常数表达式违反了附属的区域范围

end;
原文地址:https://www.cnblogs.com/rogge7/p/5993566.html