lua math.floor 實現四舍五入:
lua 中的math.floor函數是向下取整函數。
math.floor(5.123) -- 5
math.floor(5.523) -- 5
用此特性實現四舍五入
math.floor(5.123 + 0.5) -- 5
math.floor(5.523 + 0.5) -- 6
也就是對math.floor函數的參數進行 “+ 0.5” 計算
lua math.floor 實現四舍五入:
lua 中的math.floor函數是向下取整函數。
math.floor(5.123) -- 5
math.floor(5.523) -- 5
用此特性實現四舍五入
math.floor(5.123 + 0.5) -- 5
math.floor(5.523 + 0.5) -- 6
也就是對math.floor函數的參數進行 “+ 0.5” 計算
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。