var
rq,rq1:integer;
begin
rq:=10;
rq1:=rq/2;'此句出错了?

解决方案 »

  1.   

    当然拉。rq/2返回的不是integer类型拉。
    rq div 2就可以拉
      

  2.   


    div 返回整数/ 返回double
      

  3.   

    按照delphi开发人员指南的解释:Pascal中的div运算符自动借调两个整数相除的小数部分。很多编程语言对整数除法和浮点除法不加区分。而Pascal中的div运算符运算速度比较快。
      

  4.   

    ‘/’返回Extended不是Double,‘div’返回integer酌情使用。Cheers.
      

  5.   

    to cooling(cooling)整数也分好多,比如精度不同等等区分。不能一概而论,有些地方用到了Cardinal如下:Type Range Format
    Integer -147483648..2147483647 signed 32-bit
    Cardinal 0..4294967295 unsigned 32-bitFundamental integer types include Shortint, Smallint, Longint, Int64, Byte, Word, and Longword.Type Range Format
    Shortint -28..127 signed 8-bit
    Smallint -2768..32767 signed 16-bit
    Longint -147483648..2147483647 signed 32-bit
    Int64 -2^63..2^63? signed 64-bit
    Byte 0..255 unsigned 8-bit
    Word 0..65535 unsigned 16-bit
    Longword 0..4294967295 unsigned 32-bit
    In general, arithmetic operations on integers return a value of type Integer梬hich, in its current implementation, is equivalent to the 32-bit Longint. Operations return a value of type Int64 only when performed on an Int64 operand. Hence the following code produces incorrect results.
    而div返回的是Integer类型。