接:遇到一个问题: 象$D7、$08是不是代表十六进制? 如何计算一个表达式?
有一个表达式  : _Vol := _Vol or $08 or _Sound;
在未计算之前  : _Vol =7 , _Sound =7
计算后的结果是: _Vol =15可是我不知道是如何计算出来的?而我按照十六进制的计算是
  _Vol   7         0000 0111
  $08    8      or 0000 1000
                   0000 1111
  _Sound 7      or 0000 0111
  结果:            0000 1111
即十六进制的OF请问_Vol := _Vol or $08 or _Sound;是如何计算的????????
   

解决方案 »

  1.   

    or运算符对整数(运算数)的位进行处理!!
      _Vol   7         0000 0111
      $08    8      or 0000 1000
                       0000 1111
      _Sound 7      or 0000 0111
      结果:            0000 1111
    即十六进制的OF 转化成整数是多少呢?当然是15!
      

  2.   

    delphi自己带的帮助你看Logical (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.
      

  3.   

    • 位反(not)运算的返回类型和运算数相同;
    • 若and、or 或xor 的运算数都是整数类型,则它的返回类型是包含运算数所有可能的值、且范围最小的预定义(内置)整数类型;
      

  4.   

    or运算符对整数(运算数)的位进行处理!!
    即十六进制的OF 转化成十进制整数是15!