floor 和 ceil 是 math unit 里的函數(shù),使用前要先 Uses Math
trunc 和 round 是 system unit 里的函數(shù),缺省就可以用。
floor 直接往小的取,比如 floor(-123.55)=-124,floor(123.55)=123
trunc 直接切下整數(shù),比如 trunc(-123.55)=-123, floor(123.55)=123
ceil 直接往大的取,比如 ceil(-123.55)=-123, ceil(123.15)=124
round 計(jì)算四舍五入,比如 round(-123.55)=-124,round(123.55)=124
Round 是銀行家算法,5 是否進(jìn)位取決于 前面的一位是不是偶數(shù),偶數(shù),則進(jìn)位,奇數(shù),則不進(jìn)位。
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。