Delphi取整函数

发布时间 2023-05-08 13:39:56作者: lucken

 

Uses Math

floor 和 ceil 是 math unit 里的函数,使用前要先 Uses Math。
trunc 和 round 是 system unit 里的函数,缺省就可以用。
floor 直接往小的取,比如 floor(-123.55)=-124,floor(123.55)=123
trunc 直接切下整数,比如 trunc(-123.55)=-123, floor(123.55)=123
ceil 直接往大的取,比如 ceil(-123.55)=-123, ceil(123.55)=124
round 计算四舍五入,比如 round(-123.55)=-124,round(123.55)=124