mysql 取小數點 (truncate, round)

TRUNCATE(123.456, 1) = 123.4
TRUNCATE(123.456, 0) = 123
TRUNCATE(123.456, -1) = 120
TRUNCATE(-123.456, 1) = -123.4

TRUNCATE 不會四捨五入,請用 ROUND 代替

ROUND(345.678, 1) = 345.7
ROUND(344.678, -1) = 340
ROUND(345.678, -1) = 350

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *