怎样把float类型转换为int??怎么把double类型转换为int??

解决方案 »

  1.   

    Delphi syntax:function Round(X: Extended): Int64;DescriptionIn Delphi, the Round function rounds a real-type value to an integer-type value.X is a real-type expression. Round returns an Int64 value that is the value of X rounded to the nearest whole number. If X is exactly halfway between two whole numbers, the result is always the even number. This method of rounding is often called "Banker抯 Rounding".If the rounded value of X is not within the Int64 range, a runtime error is generated, which can be handled using the EInvalidOp exception.Note: The behavior of Round can be affected by the Set8087CW procedure or SetRoundMode function.
    Delphi syntax:function Trunc(X: Extended): Int64;DescriptionIn Delphi code, the Trunc function truncates a real-type value to an integer-type value. X is a real-type expression. Trunc returns an Int64 value that is the value of X rounded toward zero.If the truncated value of X is not within the Int64 range, an EInvalidOp exception is raised.
      

  2.   

    都一样的,如:
    round(3.56) ;//返回4 ,该函数四舍五入
    Trunc(3.56);//返回3,该函数只取整数部分