function Int(X: Extended): Extended;//将实数的小数部分去掉 function Trunc(X: Extended): Int64;//将实数变为整数
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. 也就是说Trunc直接取整 比如 X := trunc(5.6) X := 5; X是Int64类型,是整数Delphi syntax:function Int(X: Extended): Extended;DescriptionIn Delphi code, Int returns the integer part of X; that is, X rounded toward zero. X is a real-type expression.Int也是取整 但是 X := Int(5.6) X := 5.0 X是Extended 还是一个浮点数
function Trunc(X: Extended): Int64;//将实数变为整数
trunc将实数变为整数,返回的是64位整数;
都没有四舍五入,好像处理负数的时候不一样!
function Trunc(X: Extended): Int64;//将实数变为整数正确.
Trunc()返回的是整数
呵呵~~
trunc(x)是system的,速度快(比Math中的floor快)
老實說..到底int有什麼時候會用??除去了小數的浮點數,速度比整數慢很多,也沒有這種需要